Alternating LI background colors
-
Searching for awhile didn’t bring me the answers I’m looking for, so I’m posting.
I’m developing a custom theme for a client, and part of it involves, in the sidebar, a list of recent posts of the category “Articles”.
So for now the PHP looks like this:
<ul id="recentEntries"> <li class="entriesHead"><h3>Articles</h3></li> <?php query_posts('cat=4&showposts=10'); ?> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?> <span><?php the_time('F jS, Y') ?></span></a></li> <?php endwhile; ?> </ul>
producing HTML that looks like this:
<ul id="recentEntries"> <li class="entriesHead"><h3>Articles</h3></li> <li><a href="http://localhost/wordpress/?p=18" title="Article trois">Article trois <span>March 23rd, 2007</span></a></li> <li><a href="http://localhost/wordpress/?p=17" title="Article dos">Article dos <span>March 23rd, 2007</span></a></li> <li><a href="http://localhost/wordpress/?p=16" title="Article 1">Article 1 <span>March 23rd, 2007</span></a></li> </ul>
What I’d like to do is have every other
<li>
in that<ul>
be given a class ofalt
, so that the background colors can alternate.My PHP skills are still pretty rudimentary, so any help to this end would be terrific.
Thanks!!
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Alternating LI background colors’ is closed to new replies.