Alternate background colors for child page list (5 posts)

  1. drinkingsouls
    Posted 3 years ago #

    Hey guys, I've found some solutions to problems similar to this but I can't seem to get to work the way I need it too.

    What I'm trying to do is display child pages of a parent as a list and apply alternate an alternate background color to every other list item <li>

    All I've got so far is:
    <ol><?php wp_list_pages('title_li=&child_of=1118&sort_column=menu_order'); ?></ol>
    This lists the child pages from a specified parent but I need to add some php to apply perhaps a different class to every other <li> so that I can apply an alternate background color in css.

    Any help is much appreciated.

  2. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    May you provide a link to a website that implements something similar? I'm finding it hard to envisage what you mean.

  3. esmi
    Forum Moderator
    Posted 3 years ago #

  4. drinkingsouls
    Posted 3 years ago #

    Sure, just like on Wikipedia where it shows the Track listing for albums. Check this out:
    See how each track has a different background color?

  5. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    I see.

    Esmi's link provides information on how to use nth-child, you may want to use nth-child(odd) or nth-child(even).

Topic Closed

This topic has been closed to new replies.

About this Topic