Hey Riceman,
Instead of using this code:
// Blog Subcategories
add_filter('cs_looper_custom_subcat', function($result, $args){
$category = get_queried_object();
$cat_args = array(
'hide_empty' => 1,
'child_of'=> 1,
'taxonomy' => '$category',
);
$subcats = get_categories($cat_args);
return $subcats;
}, 10, 2);
I updated the code to this one:
// Blog Subcategories
add_filter('cs_looper_custom_subcat', function($result, $args){
$category = get_queried_object();
$cat_args = array(
'hide_empty' => 1,
'child_of' => $category->term_id,
'taxonomy' => $category->taxonomy,
);
$subcats = get_categories($cat_args);
return $subcats;
}, 10, 2);
In this corrected code:
- I replaced the
$category
in the 'taxonomy' => '$category'
line with $category->taxonomy
.
- I used
$category->term_id
for the 'child_of'
parameter to get the term ID of the current category.
With those changes, it is now showing the correct subcategories with no duplications.
Hope that helps.