Title: if latest_post?
Last modified: August 19, 2016

---

# if latest_post?

 *  [robomilk](https://wordpress.org/support/users/robomilk/)
 * (@robomilk)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/if-latest_post/)
 * Is there any way at all (plugin, hack, etc.) to get WordPress to identify whether
   the current post is the latest one published?
 * This needs to work on single post pages and ignore posts set to be automatically
   published at a later date.
 * Any ideas folks?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 5 months ago](https://wordpress.org/support/topic/if-latest_post/#post-677286)
 * You could just get the latest published post and compare the ID numbers.
 *     ```
       $latestposts = get_posts('numberposts=1');
       $latestpost = $latestposts[0];
       if (get_the_ID() == $latestpost->ID) {
       // this is the latest post
       } else {
       // it's not
       }
       ```
   
 *  Thread Starter [robomilk](https://wordpress.org/support/users/robomilk/)
 * (@robomilk)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/if-latest_post/#post-677292)
 * Took a bit of hacking together with my existing code, but it worked. Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘if latest_post?’ is closed to new replies.

## Tags

 * [if](https://wordpress.org/support/topic-tag/if/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * 2 replies
 * 2 participants
 * Last reply from: [robomilk](https://wordpress.org/support/users/robomilk/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/if-latest_post/#post-677292)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
