Skip to content

Instantly share code, notes, and snippets.

@sunriseweb
Last active January 3, 2016 03:28
Show Gist options
  • Save sunriseweb/8401928 to your computer and use it in GitHub Desktop.
Save sunriseweb/8401928 to your computer and use it in GitHub Desktop.
Modify search query using pre_get_posts in genesis theme.
<?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