• In every single post page, I want to show links and title of 10 previous posts. How to do it?

    For example:

    If I’m viewing a post created on 19th November then that page should show links and title of 10 recent posts before 19th November.

    Again, if I see a post created on 5th September then that page should show links and title of 10 recent posts before 5th September.

    How to do it?

Viewing 1 replies (of 1 total)
  • I have something sort-of similar in my sidebar… 1 post from 2004, 1 post from 2003, 1 post from 2002… etc… Someone on this forum wrote the code for me.

    But I’m not sure how to change it to do just what you wanted. If this helps, my custom code is:

    <ul>
    <?php
    $posts = get_posts('numberposts=2&category=2&offset=2');
    foreach ($posts as $post) :
    setup_postdata($post);
    ?>

    Then this:

    <a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a>
    <?php
    endforeach; ?>
    </ul></li>
    <?php
    $year = date('Y');
    $month = date('m');
    for ($x = 0; $x <= 2; $x++){
    $year--; ?>
    <li><h2>1 Radio <?php echo $year ?> Setlist</h2>
    <ul>
    <?php
    $query = new WP_Query("showposts=1&cat=2&year=$year");
    while($query->have_posts()) : $query->the_post();
    ?>
    <a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a>
    <?php endwhile; ?>
    </ul></li>
    <?php
    } // end for loop of previous year's playlists
    ?>

Viewing 1 replies (of 1 total)

The topic ‘How to show 10 previous posts (not recent posts)?’ is closed to new replies.