Created
June 4, 2012 09:48
-
-
Save antoniofrignani/2867527 to your computer and use it in GitHub Desktop.
[WP] - Search 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
// http://wpsnipp.com/index.php/posts/search-a-specific-post-type/ | |
function SearchFilter($query) { | |
if ($query->is_search) { | |
// Insert the specific post type you want to search | |
$query->set('post_type', 'feeds'); | |
} | |
return $query; | |
} | |
// This filter will jump into the loop and arrange our results before they're returned | |
add_filter('pre_get_posts','SearchFilter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment