Created
January 16, 2016 04:49
-
-
Save leowebguy/a506dd7a613924b37d46 to your computer and use it in GitHub Desktop.
wordpress change/add post types on default theme 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','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