Created
April 13, 2013 04:23
-
-
Save shrwnsan/5376927 to your computer and use it in GitHub Desktop.
WordPress: exclude custom post-types from search query results. Note: 'video-camera', 'software-solution','post' are the post types which you want to search replace with you own. Source: http://wordpress.org/support/topic/exclude-custom-post-types-from-search-query-results?replies=6#post-3249786
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
| // search filter | |
| function fb_search_filter($query) { | |
| if ( !$query->is_admin && $query->is_search) { | |
| $query->set('post_type', array('video-camera', 'software-solution','post') ); // id of page or post | |
| } | |
| return $query; | |
| } | |
| add_filter( 'pre_get_posts', 'fb_search_filter' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment