Most Recent Post ... Not Most Recent (2 posts)

  1. jabbamonkey
    Posted 3 years ago #

    I have a link I am generating for the most recent post in a category...

    $args = ('cat=57&posts_per_page=1&orderby=date&order=ASC');
    /* I've also tried */
    /* $args = array(
         'cat' => 57,
         'posts_per_page' => 1,
         'order' => 'ASC'
    $my_query = new WP_Query($args);
    while ($my_query->have_posts()) {
          $my_query->the_post(); ?>
          <a href='<?php the_permalink(); ?> ' >UP TO SPEED</a>
    <?php } wp_reset_query(); ?>

    The problem is, it is not showing the MOST RECENT post.

    The post it is showing has a published date of 2012/03/02. The problem is, there are posts in that same category that are newer:

    >> 2012/03/02 - Shows as current

    I checked that it is pulling the correct category. All of the posts above are "published" and not hidden. I also checked if it was pulling articles by revision date ... but it wasn't.

    Basically, when I add a new article in that category and hit PUBLISH, the new article doesn't appear in that link. NOTE: I have similar "links" like this for other categories and they pull the correct information.

    Please help.

  2. vtxyzzy
    Posted 3 years ago #

    I believe that the order needs to be DESC. The largest date is the most recent.

Topic Closed

This topic has been closed to new replies.

About this Topic