I am using masonry filters to filter entries on a template using category ID’s to differentiate

Filter buttons:

    <div class="masonry-filters">
<ul data-option-key="filter">
<li><a class="selected" href="#" data-option-value="*">All</a></li>
   {exp:query sql="
        SELECT *
        FROM exp_categories
        WHERE group_id IN (4)
        ORDER BY cat_name ASC"}
          <li><a href="#" data-option-value=".mansonry-filter-{cat_id} ">{cat_name}</a></li>

Then each entry has the category id in the class for filtering:

<article class="masonry-item col-sm-6 col-md-4 mansonry-filter-{categories}{category_id}{/categories} hentry"> 

The problem I have is an entry has a parent AND child category they will not be included in the filter because the ID’s are combined.

ie: USA cat id = 11 New York child id is 65 So this entry’s class will be 1165. I need to separate them so I have just the parent 11 ideally also have 65 as a separate class but not sure how that will work with my filtering.

This would be my goal:

class="masonry-item col-sm-6 col-md-4 mansonry-filter-11  mansonry-filter-65 hentry" 

EDIT: I think this is my solution

<article class="masonry-item col-sm-6 col-md-4 {exp:gwcode_categories entry_id="{entry_id}" style="linear"} mansonry-filter-{cat_id} {/exp:gwcode_categories} hentry">

1 Answer 1


I might be missing something but aren't you able to accomplish that like this?

<article class="masonry-item col-sm-6 col-md-4 {categories}mansonry-filter-{category_id} {/categories} hentry">

This would output what you desire. I know nothing about masonry filters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.