How to looping parent category also with child category only. (4 posts)

  1. erikdewangga
    Posted 3 years ago #

    Halo, anybody here's know how to looping post for category parent and also the child category. i want to styling post that different category.
    for example:

    Parent category 1 (Style 1)
    - child category a (Style 1)
    - child category b (Style 1)


    Parent category 2 (Style 2)
    - child category a (Style 2)
    - child category b (Style 2)


    Thanks :)

  2. tiaanswart
    Posted 3 years ago #

    Try using the is_category function: http://codex.wordpress.org/Function_Reference/is_category

    conditional statements like these might help:

    <?php if (is_category('1')); ?>
    //Post style 1 here 
    <?php elseif (is_category('2')); ?>
    //Post style 2 here 
    <?php endif; ?>
  3. erikdewangga
    Posted 3 years ago #

    How about the child category? every category have different ID's right...

  4. erikdewangga
    Posted 3 years ago #

    I mean every child category just follow the style of parent category automaticly without make another code and inserting the ID's... is it possible?

Topic Closed

This topic has been closed to new replies.

About this Topic