Grow your CSS skills. Land your dream job.

Need to list subcategories while using isotope in wordpress

  • # November 28, 2012 at 11:16 am

    Hi I’m using isotope to navigate a client site I’m working on. I’ve gotten the parent categories to list and do what they are suppose to do but the subcategories aren’t displaying. Any help would be greatly appreciated.

    An example of what I’m trying to achieve can be found here http://ifactory.ca/dev/sensei_grid/

    <dl class="accordion" id="filter" data-option-key="filter">
    <dt><h2><a href="#" data-filter="*" id="showall" class="selected about-senseitop close-subnav filter-item">All</a></h2></dt>
    <?php
    $args=array(
    'orderby' => 'name',
    'order' => 'ASC'
    );
    $categories=get_categories($args);
    foreach ($categories as $cat) { ?>
    <dt><a href="#" class="customer-acquisitiontop" id="<?php echo $cat->slug; ?>" data-filter=".<?php echo $cat->slug; ?>"><h2><?= $cat->cat_name; ?></h2></a></dt>
    <dd class="services">
    <ul class="row">
    <li class="< ?php echo $cat->slug; ?>">
    < ?php $cat = get_categories('child_of='); ?>
    </li>
    </ul>
    </dd>
    <?php } ?>
    </dl>
    # November 28, 2012 at 12:08 pm

    You might want to try instead of doing a custom category loop trying wp_list_categories (http://codex.wordpress.org/Template_Tags/wp_list_categories) and seeing if that gives you the right stuff (and maybe you can just work with that markup).

    Otherwise you’ll need to dig into what $categories is turning out to be and adjust your loop to output the right stuff. It’s probably very close, just some syntax issues (I’m not quite sure).

    # November 28, 2012 at 1:10 pm

    Thanks Chris I’ll give those options a try. Greatly appreciated.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".