WordPress.org

Ready to get started?Download WordPress

Forums

Alternate background colors for child page list (5 posts)

  1. drinkingsouls
    Member
    Posted 1 year 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.
    Thanks,
    Chris

  2. Andrew
    Forum Moderator
    Posted 1 year 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 1 year ago #

  4. drinkingsouls
    Member
    Posted 1 year ago #

    Sure, just like on Wikipedia where it shows the Track listing for albums. Check this out:
    http://en.wikipedia.org/wiki/I_Brought_You_My_Bullets,_You_Brought_Me_Your_Love
    See how each track has a different background color?
    Thanks

  5. Andrew
    Forum Moderator
    Posted 1 year 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