Listing search does not work

Hello.
I have set up a search form for Listings page, but neither the keyword search nor the category search searches within the listings.
It seems to only search for articles outside of HivePress.
Is there a solution to this problem?

Sorry.
It was because I added Code to not display anything other than blog posts in the search results.

I don’t want fixed pages to appear in the search results on my site, is there any PHP code that doesn’t affect the listing search?

I was using this…

function mycus_search_filter_post_only_func( $query ) {
    if ( $query->is_search() && $query->is_main_query() && ! $query->is_admin() ) {
        $query->set( 'post_type', 'post' );
    }
    return $query;
}
add_filter( 'pre_get_posts', 'mycus_search_filter_post_only_func' );

Yes, this snippet sets the “post” type for any search queries, so it overrides the listing search query (listings have “hp_listing” post type). This snippet is not required if you use our Listing Search Form. If you use some custom search form please add a hidden input to it with “post_type” name and “hp_listing” set as value, then it’ll redirect users to the listing search results.

You’ve been helpful! Thank you!

1 Like