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:
- wp_enqueue_script adding conditional statement not working
- 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
- 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
- Next/Previous Posts Links: Alphabetically and from Same Category
- Problem excluding category from get_next_post
- Why is previous_post_link and next_post_link working outside of the Loop?
- Disable “previous link” in first post and “next link” in last post
- previous / next post with thumbnail
- next_posts_link not working in custom loop
- Show prev and next post links for parent post of current image in attachment page?
- 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?
- next_post_link and previous_post_link in custom post type single page, in same non-custom category
- Condition function for is parent category?
- previous_post_link() next_post_link() arrow position
- Conditional Statement – Best Way to Remove Nav on Contact Page
- Proper syntax for simple conditional bloginfo language
- 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!
- 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?
- 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
- Previous/next post links displaying wrong category than is desired
- Next Posts Prev Posts for Standard post format only
- 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
- How to use “Cases” instead of “IFs” for conditional logic
- Modify previous and next post links to current Authors Other posts
- Link to the next/prev posts in index loop in same category?
- if/Else have_posts Else fails to echo message to page
- Return function only on certain pages
- Single: Prev and next Post in same order as main query, in all categories
- How to write this conditional statement?
- query_posts pagination will always show identical content
- Show this code if user has previously left a comment
- altering %title
- How can I use ‘edit_form_after_title’ conditionally?
- Get ID for previous/next image link
- Pagination for custom loop on custom page template is not displaying anything
- Include scheduled ( future ) posts in WordPress post navigation ( previous_post_link, next_post_link )
- Conditional loading of CSS for my plugin
- Custom Posts and Posts – next_post_link and previous_post_link not working together
- using images in next/previous_post_link [closed]
- Display next 3 posts based on custom taxonomy
- Next Prev Post link rendering current post thumbnail
- Looks like this if condition is not working [closed]
- grab neighboring content in a query
- WP_Query and pagination AGAIN?
- Generating images from an array of categories
- Include “Scheduled” (“Future”) Posts in WordPress Post Navigation ( previous_post_link, next_post_link ) for a Specific Custom Post Type
- Next/Previous Product with custom order by price & products inside the product category [closed]
- Order by post_date does not work in Previous and Next post pagination
- Infinite next / prev post in single.php page
- How to exclude posts by meta key value in the_post_navigation next prev links?
- WP conditional site logo and header block
- Change URL of previous posts and next posts link in WordPress
- next_posts_link not visible on first page
- Previous/Next custom post links within custom taxonomy
- How to filter get previous post function by meta value DESC and post date DESC?
- previous and next post of same category on singlepost.php
- How do I modify the Previous and Next Page posts on blog pages to include “previous” and “next” before the links?
- How to Navigate within Category? Lot of codes here on stackexchange didn’t work
- How do I use the add_query_arg function in a template tag like previous_post_link?
- Widget logic conditional widget
- How to display image on condition that a selection has been made
- Need help with get_posts pagination
- Next/Prev category post in same button
- How to Conditionally Not Display a Link Based on Current URL?
- Allow users to only CREATE one single (custom) post
- using next-page and previous page inside a wp_query
- show previous/next post orderer by title in custom post types
- previous_posts_link returns null when querying custom post type
- customize urls displayed by previous_post_link and next_post_link
- Post in multiple categories do not include in previous / next post if one category in excluded
- single post navigation order (NOT chronological)
- Single post navigation Previous post link shows up but Next post link doesn’t
- why is my custom loop failing?
- Change next_post and previous_link to navigate throught parent categories only
- Conditional sidebar menu
- What is the best way to disable my WP website if the user has adblocker on? [closed]
- pagination/prev and next page links not showing
- Multiple loops using next_posts_link & previous_posts_link
- Previous / next posts using featured image thumbnail as links
- Next/previous post link to posts only within one or more specific categories
- How to add thumbnail support to WordPress next / previous post loop?