Sounds like WordPress does not support this out of the box. However, you can get the most recent post via wp_get_recent_posts()
, and then check against the result from there.
Here I am using array_shift()
to turn the array containing one post into the post itself.
$args = array(
'numberposts' => 1,
'post_status' => 'publish',
);
$most_recent_post = array_shift(wp_get_recent_posts( $args, ARRAY_A ));
$next_post = get_next_post();
if (!empty( $next_post )) {
// is the next post the most recent post?
if ($most_recent_post['ID'] === $next_post->ID) {
// next post is most recent post
} else {
// next post is not most recent post
}
}
Related Posts:
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- is it possible to get next_post_link
- Get Previous & Next posts by Post ID
- Filter next_post_link() and previous_post_link() by meta_key?
- wp_enqueue_script adding conditional statement not working
- How can I add title attributes to next and previous post link functions?
- Check if first paragraph is an image, then show custom code right after it?
- How to get next and previous post links, alphabetically by title, across post types, in a shortcode
- get_adjacent_post alternative on a very large db
- How can I get next/ previous post links to order by a filter (by the last word of the title)?
- next and previous post link ordered alphabetically
- Thumbnail (featured image) of next and previous post is not being properly displayed!
- How can I limit the length of the previous/next posts in my WordPress Theme?
- If post author role is X
- How to use next_post_link and previous_post_link on single posts in search results
- Can a conditional statement apply to part of a slug?
- Next/Previous Posts Links: Alphabetically and from Same Category
- How can I get next post id after current post id for custom post type
- Problem excluding category from get_next_post
- Why is previous_post_link and next_post_link working outside of the Loop?
- adding custom fields to next and previous post link
- specify meta_key / meta_value condition for prev_post_link and next_post_link
- Using previous_post_link and next_post_link to wrap around post sequence
- Add default content to posts in a specific category?
- Disable “previous link” in first post and “next link” in last post
- previous / next post with thumbnail
- is_front_page, is_page(‘slug’), is_page(id) not working
- next_posts_link not working in custom loop
- Making next_posts_link(); return posts by month
- Show prev and next post links for parent post of current image in attachment page?
- WordPress previous_post_link exclude posts with multiple categories
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- Showing Thumbnail from Previous and Next Posts
- Next and prev. post link ONLY within category
- Need help on creating If-statement for custom meta fields
- How to make gravatar.com avatars conditional?
- Working with Next and Prev links in Single Taxonomy Templates
- How to make my pagination loop continuously?
- Previous/Next Post Within the Category?
- Loading Scripts on Specific Pages
- next_post_link and previous_post_link in custom post type single page, in same non-custom category
- Next and Previous links on a single taxonomy page only link to same term
- Get attachment next and previous by author only
- connect last post with first post
- Condition function for is parent category?
- previous_post_link() next_post_link() arrow position
- “next_posts_link” and “previous_posts_link” display me NOTHING
- Conditional Statement – Best Way to Remove Nav on Contact Page
- Proper syntax for simple conditional bloginfo language
- Can I use get_adjacent_post for specific categories?
- Add #anchor to next/previous_post_link
- Next and/or previous post content
- wordpress is_page() problem
- Previous_post and Next_post – Custom Post Type
- Location-Based Content
- next_post_link for CPT only working for a few posts? weird!
- Is it possible to nest get_previous_post()?
- Personalized message for each unique password-protected page
- Exclude Posts From Specific Category from Next and Previous post links
- Is it possible to skip certain specified pages when using < prev and next > links?
- Conditional Shortcode image display
- Why do next pages load the same content rather then older articles?
- Next and Previous Posts of Same Parent
- Show category from “Next post” and “Previous post” [edited]
- previous/next_post_link in the same sub-category?
- Change Woocommerce order button page on particular page
- Using ‘previous_post_link()’ & ‘next_post_link()’ on single attachment pages
- Previous/next post links displaying wrong category than is desired
- Next Posts Prev Posts for Standard post format only
- get_adjacent_post – in same term or category not working
- next_post_link and previous_post_link order not working properly
- Change a url / link if a user is logged in?
- Get Adjacent Post By Tag
- to create own conditional tags for business directory in wp
- get_next_post_link() and get_previous_post_link() return wrong posts
- previous_posts_link and next_posts_link, how to return the next/previous post’s title as the url
- How to use “Cases” instead of “IFs” for conditional logic
- WordPress next/prev links Issue
- Which is the better way to write a conditional statement? [closed]
- Modify previous and next post links to current Authors Other posts
- Nested conditionals
- Link to the next/prev posts in index loop in same category?
- Is there a way to password-protect part of a post?
- next_post_link / previous_post_link not working with WP_Query
- if/Else have_posts Else fails to echo message to page
- Conditonal statement for iPad
- Return function only on certain pages
- Displaying the author of next and previous posts in pagination?
- Single: Prev and next Post in same order as main query, in all categories
- How to exclude or filter password protected posts when using next_post_link() previous_post_link
- Single.php Category Post Count
- How to write this conditional statement?
- Why are previous_post_link/next_post_link skipping some posts?
- Add Previous/Next Buttons to CPT Single Pages Only
- query_posts pagination will always show identical content
- Conditional for Custom Post Types
- Date-Based Conditional Tag
- Message box when accessed from iPad
- WordPress post pagination continuous [duplicate]
- Get previous/next post from (specific) category