WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. erikdewangga
    Member
    Posted 1 year 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)

    and

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

    etc.

    Thanks :)

  2. tiaanswart
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

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

  4. erikdewangga
    Member
    Posted 1 year 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