Last active
January 3, 2016 03:28
-
-
Save sunriseweb/8401928 to your computer and use it in GitHub Desktop.
Modify search query using pre_get_posts in genesis theme.
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 | |
/** | |
* Customize Search Query | |
* | |
* @author Brad Trivers | |
* @link http://sunriseweb.ca | |
* @param object $query data | |
* | |
*/ | |
add_action( 'pre_get_posts', 'hotbuys_search_query' ); | |
function hotbuys_search_query( $query ) { | |
if( $query->is_main_query() && is_search()) { | |
$meta_query = array( | |
array( | |
'key' => 'client_status', | |
'value' => array('active'), | |
'compare' => 'IN' | |
), | |
); | |
$query->set( 'meta_query', $meta_query ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment