Exclude unapproved drafts from search results
-
Hi,
I need to exclude unapproved posts submitted by my users from my search results.
I tried applying this in my functions.php file
function mySearchFilter($query) { if ($query->is_search) { $query->set('post_status', 'publish'); } return $query; } add_filter('pre_get_posts','mySearchFilter');
but it did not work. I also tried other solutions, but nothing worked.
Any ideas? Thanks in advance!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Exclude unapproved drafts from search results’ is closed to new replies.