Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('relevanssi_modify_wp_query', 'mrb_tax_query');
- function mrb_tax_query($query) {
- $tax_query = array();
- if (!empty($query->query_vars['asset_class'])) {
- $tax_query[] = array(
- 'taxonomy' => 'asset-class',
- 'field' => 'slug',
- 'terms' => $query->query_vars['asset_class'],
- 'operator' => 'IN'
- );
- }
- if (!empty($query->query_vars['region'])) {
- $tax_query[] = array(
- 'taxonomy' => 'region',
- 'field' => 'slug',
- 'terms' => $query->query_vars['region'],
- 'operator' => 'IN'
- );
- }
- if (!empty($query->query_vars['economy'])) {
- $tax_query[] = array(
- 'taxonomy' => 'economy',
- 'field' => 'slug',
- 'terms' => $query->query_vars['economy'],
- 'operator' => 'IN'
- );
- }
- if (!empty($query->query_vars['report_type'])) {
- $tax_query[] = array(
- 'taxonomy' => 'report-type',
- 'field' => 'slug',
- 'terms' => $query->query_vars['report_type'],
- 'operator' => 'IN'
- );
- }
- if (!empty($tax_query)) {
- $tax_query['relation'] = 'AND'; // you can also use 'OR' here
- $query->set('tax_query', $tax_query);
- $query->set('orderby', 'date');
- $query->set('order', 'DESC');
- }
- return $query;
- }
Advertisement
Add Comment
Please, Sign In to add comment