I have the following portfolio structure:
Cat. 1
– Sub Cat. 1
Cat. 2
– Sub Cat. 2
I have a portfolio item which is part of Cat. 1 and Sub Cat. 1
When i create a page with Cat. 1 and Cat. 2 with filtering, the filter should only show Cat. 1 and Cat. 2 as options but it also shows Sub Cat. 1. I tried everything but if an item is part of two or more categories, all of these categories are shown as filter even if i only select one for the portfolio page.
Open up wp-contentthemesenfoldconfig-templatebuilderavia-shortcodesportfolio.php and replace:
if(in_array($category->term_id, $current_page_cats, true))
with
if(in_array($category->term_id, $current_page_cats, true) && !(in_array($category->category_parent, $current_page_cats, true)))
Thanks, but this is not working. Now the top cat. will be shown everytime even if i only select the sub categories for the portfolio grid. I only want the for the grid selected categories to be shown as filter options.
Ah, ok – didn’t understand it properly the first time. In this case revert the change and replace:
$output = "<div class='sort_width_container' ><div id='js_sort_items' >";
with:
$display_cats = is_array($params['categories']) ? $params['categories'] : explode(',',$params['categories']);
$output = "<div class='sort_width_container' ><div id='js_sort_items' >";
and
if(in_array($category->term_id, $current_page_cats, true))
with
if(in_array($category->term_id, $display_cats, true))
I’ll mark this thread for Kriesi because imo it makes more sense to show just the selected cats in the filter bar.