Created
February 22, 2019 03:55
-
-
Save tradesouthwest/248574254c81e882249e97039a661c64 to your computer and use it in GitHub Desktop.
modifies the main WordPress query to include an array of post types
This file contains hidden or 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
<?php | |
/** | |
* 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 trunkline_custom_search_query( $query ) { | |
if ($query->is_search) { | |
$query->set( 'post_type', array( 'post', 'job_listing', 'products', 'page' ) ); | |
} | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'trunkline_custom_search_query'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment