• thunderdust

    (@thunderdust)


    HI guys,

    At the moment I use this to show my latest posts.

    <?php
    $myposts = get_posts('numberposts=10&offset=1');
    foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title();
    ?></a></li>
    <?php endforeach; ?>

    This will make a list of all the items. I want the color of the rows to Toggle, so row1:=white row2:=gray row3:=white.

    Is this possible? if so, how ?

Viewing 1 replies (of 1 total)
  • Adam Brown

    (@adamrbrown)

    try:

    <?php
    $myposts = get_posts('numberposts=10&offset=1');
    $alt = 'white';
    foreach($myposts as $post) :
    ?>
    <li class="<?php echo $alt; ?>"><a href="<?php the_permalink(); ?>"><?php the_title();
    ?></a></li>
    <?php $alt = ('white'==$alt) ? 'gray' : 'white'; ?>
    <?php endforeach; ?>

    In your css:

    .white{background:#fff;}
    .gray{background:#aaa;}

    Enjoy.

Viewing 1 replies (of 1 total)
  • The topic ‘Color Toggle With List’ is closed to new replies.