Viewing 3 replies - 1 through 3 (of 3 total)
  • You can always add to the parameters of your search to start. I will be needing to do the same thing pretty soon once I customize the rest of my product pages to display the way I want. I would suggest checking out the database to see the post type of the products post. when I do a search using the products search I can see that it adds “post_type=al_product” to the query. This page may help you as well: https://premium.wpmudev.org/blog/build-your-own-custom-wordpress-search/

    This article also mentions you can add multiple post_types into hidden fields: https://wordpress.stackexchange.com/questions/12723/searching-multiple-custom-post-types-and-pages

    If you want to use post_type post and al_product you can try this method as well to see how it works.

    I just added this under my search <form>:

    <input type="hidden" name="post_type" value="al_product">
    <input type="hidden" name="post_type" value="post">

    It worked for me, the search is now pulling both products and posts. you may have to re-format the way your search results are displayed though.

    Here’s one last way I know can work. Enter this into your functions.php in your theme directory:

    function filter_search($query) {
        if ($query->is_search) {
    	$query->set('post_type', array('post', 'al_product'));
        };
        return $query;
    };
    add_filter('pre_get_posts', 'filter_search');
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search Results’ is closed to new replies.