Plugin messes with pre_get_posts
-
I have a couple of pages I don’t want to show in the search results, so I used the pre_get_posts filter and posts__not_in. Got it working.
Next step was to make custom fields searchable. Found this plugin and installed. But after that the posts__not_in did not work.
My code below (posts_per_page setting works):
function search_exclude_pages($query) { if ($query->is_search) { $query->set('posts_per_page', '-1'); $query->set('post__not_in',array(74,78)); } return $query; } add_filter('pre_get_posts','search_exclude_pages');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Plugin messes with pre_get_posts’ is closed to new replies.