Ommiting Pages from Search results but NOT in Edit Mode
-
Hello all,
I have one question regarding omitting pages from search results. I would like to omit content that uses the Page templates and only return Posts. I am able to do that with the code below and it works great on the front-end.
The issue I’m experiencing is that this same code omits pages from internal search. For example, I want to cross-link some pages and when I do a search in the Insert/edit link within the Editor no pages are returned. Can anyone help me find a solution where I can omit from the front end but still be able to search in the Editor? Thanks in advance!
Code added to functions.php:
`<?php
function mySearchFilter($query) {
if ($query->is_search) {
$query->set(‘post_type’, ‘post’);
}
return $query;
}add_filter(‘pre_get_posts’,’mySearchFilter’);
?>’
- The topic ‘Ommiting Pages from Search results but NOT in Edit Mode’ is closed to new replies.