Created
May 30, 2017 14:26
-
-
Save mateusneves/969920b3b96020538c0be34baf6c48f8 to your computer and use it in GitHub Desktop.
Limit search to a specific post type
This file contains hidden or 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 searchfilter($query) { | |
if ($query->is_search && !is_admin() ) { | |
$query->set('post_type',array('post','page')); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts','searchfilter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment