I am outputting a list of categories for entries which have prices using the code below, how can I filter it to only show unique categories? Right now it is showing multiple categories with the same name.

{exp:channel:entries channel="channel_name" dynamic="off"}
{if price}
        {exp:gwcode_categories entry_id="{entry_id}" style="linear"}{if depth == 2}{cat_url_title}{/if}{/exp:gwcode_categories}

Ok, found a way using Stash and unique filter.

 {exp:stash:set_list name="products" parse_tags="yes" parse_depth="2"}
    {exp:channel:entries channel="channel_name"}
        {if price}
            {exp:gwcode_categories entry_id="{entry_id}" depth="2"}

        <select><option value="">Step 2. Select Option</option>
            {exp:stash:get_list name="products" unique="yes" orderby="item_name" sort="asc"}
            <option class="{parent_item_title}" value="{item_url}">{item_name}</option>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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