• Currently I’m displaying the top 5 recent posts on my static home page with this…

    <ul>
    <?php wp_get_archives('type=postbypost&limit=5'); ?>
    </ul>

    I want to style each LI independently so that the most recent post is the largest and the next is smaller and the next smaller than that etc. I have the styles done but I need to know how to tell WP to add a class name to each LI with like a number or letter to decipher the first, second, third, etc…

    So the output I’d want something like this:

    <ul>
    <li class="recent1">link 1</li>
    <li class="recent2">link 2</li>
    <li class="recent3">link 3</li>
    <li class="recent4">link 4</li>
    <li class="recent5">link 5</li>
    </ul>

    Thank you in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • I don’t think wp_get_archives() could do that. Perhaps try get_posts() followed by foreach() with an increment.

    You could try to take a look at the Fold Page List plugin. It’s got some code in there that you could use do do what you wanted to. (I’ve done this very thing before – I needed each LI to have a class, as well, so I borrowed the fold page list plugin and edited it a bit for my needs. Worked fine!)

    Thread Starter Chuck Reynolds

    (@ryno267)

    I’m not getting how to do the incremental class names with get_posts()

    I’m trying to run this within a page post with runPHP also.

    Any help azaozz? or anybody else?

    Wish I could find a site with that I’m trying to do for an example…

    Try something like this in your theme’s sidebar.php:

    <?php
     $myposts = get_posts('numberposts=5');
     foreach($myposts as $key => $post) {
     ?>
        <li class="recent<?php echo $key; ?>"><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></li>
     <?php } ?>

    Thread Starter Chuck Reynolds

    (@ryno267)

    score… that seems to work fine and dandy…

    thanks again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Need to distinguish LI’s independently from wp_get_archives’ is closed to new replies.