Skip to content

Instantly share code, notes, and snippets.

@tersor
Created February 1, 2013 22:43
Show Gist options
  • Save tersor/4694683 to your computer and use it in GitHub Desktop.
Save tersor/4694683 to your computer and use it in GitHub Desktop.
Include custom post type in WordPress search
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