Created
February 1, 2013 22:43
-
-
Save tersor/4694683 to your computer and use it in GitHub Desktop.
Include custom post type in WordPress search
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
add_filter( 'pre_get_posts', 'cpt_search' ); | |
function cpt_search( $query ) { | |
if ( $query->is_search ) | |
$query->set( 'post_type', array( 'post', 'page', 'movies', 'products', 'portfolio' ) ); | |
return $query; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment