• mmdwc

    (@mmdwc)


    Hello,

    I’m trying to display on an archive page all the children category from a parent category bu ID.

    My category ID is 4.

    Here what I’ve used so far.

    <?php $args = array(
    'child_of' => 4,
    'style' => 'none'	);
    wp_list_categories($args); ?>

    Using this code I get all my children categories list with permalink.

    What I’m trying to do is to get the category slug and name separatly.

    here is my example :

    Parent Category name is Color, Id is 4.
    my Child categories are :

    name : Blue, Slug : blue
    name : Red And Yellow, Slug : red_and_yellow
    name : Green And Brown, Slug : green_and_brown

    I need to output my category list like this :

    <li class="filter" data-filter=".blue"><a href="#blue">Blue</a></li>
    <li class="filter" data-filter=".red_and_yellow"><a href="#blue">Red And Yellow</a></li>
    <li class="filter" data-filter=".green_and_brown"><a href="#blue">Green And Brown</a></li>

    In fact I need to have separate slug & name to echo in my custom li list.

    Is there a way of doing it ?

    thanks a lot for your help

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘display children category by ID on page’ is closed to new replies.