Last active
July 9, 2018 16:53
-
-
Save LeoLopesWeb/f4ac4714929593bf056c5c9ac1da1eb8 to your computer and use it in GitHub Desktop.
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', 'tgm_io_cpt_search' ); | |
/** | |
* This function modifies the main WordPress query to include an array of | |
* post types instead of the default 'post' post type. | |
* | |
* @param object $query The original query. | |
* @return object $query The amended query. | |
*/ | |
function tgm_io_cpt_search( $query ) { | |
if ( $query->is_search ) { | |
$query->set( 'post_type', array( 'post', 'doc' ) ); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment