Where do I put this custom code?
add_filter('asp_pre_get_front_filters', 'asp_change_tax_filter', 10, 2);
function asp_change_tax_filter($filters, $type) {
// --- DO NOT CHANGE ANYTHING BELOW ---
if ( is_archive() ) {
$term_id = get_queried_object()->term_id;
if ( empty($term_id) )
return $filters;
$taxonomy = get_queried_object()->taxonomy;
foreach ($filters as $k => &$filter) {
$term_id = get_queried_object()->term_id;
if ( $type == 'taxonomy' && $filter->data['taxonomy'] == $taxonomy ) {
$filter->unselect();
$filter->select($term_id);
}
}
}
return $filters;
}
Where do I put this custom code?
add_filter('asp_pre_get_front_filters', 'asp_change_tax_filter', 10, 2);
function asp_change_tax_filter($filters, $type) {
$taxonomies = 'category, post_tag'; // Comma separated list of taxonomies
// --- DO NOT CHANGE ANYTHING BELOW ---
if ( is_archive() ) {
$term_id = get_queried_object()->term_id;
if ( empty($term_id) )
return $filters;
$taxonomies = explode(',', $taxonomies);
foreach ( $taxonomies as $taxonomy ) {
$taxonomy = trim($taxonomy);
foreach ($filters as $k => &$filter) {
if ($type == 'taxonomy' && $filter->data['taxonomy'] == $taxonomy) {
$filter->unselect();
$filter->select($term_id);
}
}
}
}
return $filters;
}
$taxonomy (string) - comma separated list of taxonomy names, where you want the code to apply