Created
August 4, 2014 22:41
-
-
Save marpstar/afcae0a0ddb4c64dc634 to your computer and use it in GitHub Desktop.
Limit WordPress search results to certain post types.
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
/* limit search to pages only - works as of WordPress 3.9.1 */ | |
function mySearchFilter($query) { | |
if ($query->is_search) { | |
$query->set('post_type', array('page', 'tribe-events')); | |
}; | |
return $query; | |
}; | |
add_filter('pre_get_posts','mySearchFilter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment