• I’m using the following code below to display the 3 most recent posts from category 4. The problem is it skipping the most recent post and displaying the 3 posts following the most recent??

    <?php
    global $post;
    $myposts = get_posts(‘numberposts=3&offset=1&category=4’);
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>

    any suggestions???

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try eliminating &offset=1 or changing it to &offset=2.

    I’m not sure if that’s the solution or not as I’m not familiar with that code, but just glancing at it…

    Just get rid of the “&offset=1″… Your code is asking wordpress to display 3 post after the first one.

    S.

    Thread Starter waveminded

    (@waveminded)

    Works like a charm! Thanks!

    I am using the same code, and it is calling 3 posts, but somehow is not the most recent 3 posts, instead it is calling the very first 3 posts.
    Does anyone know why??

    The page is sitting outside the weblog directory “news” and with this code:

    <?php
    require('./news/wp-blog-header.php');
    ?>
    
      <?php
    
    			global $post;
     $lastposts = get_posts('numberposts=1');
     foreach($lastposts as $post) :
        setup_postdata($post);
     ?>
     <span class="greybold"><?php the_title(); ?></span>
    <?php the_content_rss('', TRUE, '', 20); ?>
     <?php endforeach; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘most recent posts’ is closed to new replies.