Created
July 22, 2015 04:34
-
-
Save leobaiano/c7a6748a71e50984e25f to your computer and use it in GitHub Desktop.
Filotro de busca WordPress com taxonomys
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
<?php | |
function filter_search( $query ) { | |
if ( !is_admin() && $query->is_main_query() && $query->is_search ) { | |
$tax_query = array( | |
array( | |
'taxonomy' => 'frutas', | |
'field' => 'slug', | |
'terms' => 'laranja' | |
), | |
array( | |
'taxonomy' => 'frutas', | |
'field' => 'slug', | |
'terms' => 'maca' | |
), | |
'relation' => 'AND' | |
); | |
$query->set( 'tax_query', $tax_query ); | |
} | |
} | |
add_action ('pre_get_posts', 'filter_search' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment