• Resolved sollynz

    (@sollynz)


    Hi There,

    So in a custom sidebar im listing posts from a category called inspiration but i want to exclude the two most recent posts that get posted in that category ?

    here is my code so far

    <?php $my_query = new WP_Query('category_name=inspiration&showposts=8');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
    
       <?php $permalink = get_permalink(); ?>
    
     <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
       <!-- Do stuff... -->
      <?php endwhile; endif; ?>

    any help would be greatly appreciated

Viewing 1 replies (of 1 total)
  • Thread Starter sollynz

    (@sollynz)

    Solved

    changing my first line to

    <?php $my_query = new WP_Query(‘category_name=inspiration&showposts=8&offset=2‘);

    seemed to solve this 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Excluding the most recent 2 posts’ is closed to new replies.