• muism4t

    (@muism4t)


    I want to display my archive links in two parts: The last three posts on top of my sidebar, the rest of the posts more lower in the sidebar.

    Calling wp_get_archives for the last three posts is no problem:
    <?php wp_get_archives('type=postbypost&limit=3'); ?>

    However, when reading The list of parameters for wp_get_archives I don’t see a parameter to specify which posts to exclude , or where to start displaying past posts.
    Is there anyone who knows how to do this ?

Viewing 1 replies (of 1 total)
  • MichaelH

    (@michaelh)

    Might need to resort to something like this, either in the sidebar.php of your theme or a PHP Code Widget:

    <?php
        $args=array(
          'offset'=>3,
          'showposts'=>5,
          'caller_get_posts'=>1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'Skipping 3 posts';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          endwhile;
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Display archive posts except last three’ is closed to new replies.