WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] recent posts without the latest post (3 posts)

  1. amica12
    Member
    Posted 4 years ago #

    How do I list recent posts but make an exception for the very latest post?

    Does anyone know of a widget/plug-in that does this. Or a code snippet that would call such a list?

  2. MichaelH
    Member
    Posted 4 years ago #

    <?php
    $args=array(
      'offset'=> 1,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 5,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo '5 latest posts offset by one';
      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;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  3. amica12
    Member
    Posted 4 years ago #

    Thanks Michael - "offset" was the term I needed to search for. I found this, too:

    http://trulydotnet.wordpress.com/2010/02/06/posts-list-with-offset/

Topic Closed

This topic has been closed to new replies.

About this Topic