Searching Listings vs Posts/Pages
As I understand it so far, the theme search function at the top of our Vantage site searches 1) business listings and 2) events.
The
WP Search Widget in the sidebar, however, searches 1) pages and 2) posts.
I've struggled to find a plug in (as much as I hate to add another one) which includes EVERYTHING -- posts, pages, and listings -- in the search results.
It's frustrating to need two different types of searches, neither of which seem to cooperate with the other. I did find the "Search Everything" plug in as recommended by "Dave's Live Search" but that, too, only searches posts and pages, and not Vantage listings.
I tried added a line of code to our functions.php file (in a child theme) as shown below, as recommended on a forum post, to include the following code, but, it appears adding "listings" where shown isn't correct (or complete).
Does anyone have input, ideas, plug-in recommendations, or code hacks we can use to make sure that the sidebar search widget includes listings in the results?
-----------------------
code added to child theme functions file, which wasn't correct/adequate
-------------------------
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'listings'));
};
return $query;
};
add_filter('pre_get_posts', 'filter_search');