Skip to content

Instantly share code, notes, and snippets.

@leowebguy
Created January 16, 2016 04:49
Show Gist options
  • Save leowebguy/a506dd7a613924b37d46 to your computer and use it in GitHub Desktop.
Save leowebguy/a506dd7a613924b37d46 to your computer and use it in GitHub Desktop.
wordpress change/add post types on default theme search
add_filter('pre_get_posts','search_filter', 99); //use 99 to override/priorize this filter
function search_filter( $query )
{
if ( $query->is_search )
{
//use this for more than one post type;
$query->set( 'post_type', array('post','page','jobpost') );
//use this (uncomment) for only one post type
//$query->set( 'post_type', 'post' );
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment