Created
February 17, 2017 21:18
-
-
Save lukad03/bca0c891f6c1d5f7289919efb6d48a25 to your computer and use it in GitHub Desktop.
Wordpress Search Filtering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prefix_search_filter($query) { | |
//is_admin check prevents Search Archive in Dashboard from breaking | |
if (!is_admin() && $query->is_search) { | |
//Set the Query Options Here, e.g. $query->set('post_type', 'post'); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'prefix_search_filter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment