|
Excluding a specific category from posts view with front end filter…
Started by: riccardoU
in: Toolset Professional Support
Quick solution available
Problem:
The user would like to exclude posts assigned to a certain taxonomy term. And also be able to use a filter on the same taxonomy.
Solution:
This will require custom code such as:
add_filter( 'wpv_filter_query', 'exclude_terms_func', 10, 3 );
function exclude_terms_func($query, $setting, $views_ID)
{
if($views_ID == 3346) // your view id
{
$query['tax_query'][] = array(
'taxonomy' => 'book-author', // taxonomy name
'field' => 'slug',
'terms' => array( 'adam', 'adam2016' ), // term slug for exclude
'operator' => 'NOT IN'
);
$query['tax_query']['relation'] = 'AND';
}
return $query;
}
Relevant Documentation:
|
|
2 |
17 |
3 years, 11 months ago
riccardoU
|