Support » Fixing WordPress » recent posts without the latest post

  • Resolved amica12

    (@amica12)


    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?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().
    ?>

    Thanks Michael – “offset” was the term I needed to search for. I found this, too:

    Posts list with offset

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘recent posts without the latest post’ is closed to new replies.