Yes, the_post_navigation()
works outside of the loop on single post views.
Following the function calls, the_post_navigation()
uses get_the_post_navigation()
which uses get_previous_post_link()
and get_next_post_link()
which use get_adjacent_post_link()
which finally uses get_post()
which defaults to the global $post
object.
Here’s an excerpt of get_adjacent_post_link()
:
function get_adjacent_post_link( $format, $link, $in_same_term = false,
$excluded_terms="", $previous = true, $taxonomy = 'category' ) {
if ( $previous && is_attachment() )
$post = get_post( get_post()->post_parent );
else
$post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
if ( ! $post ) {
$output="";
} else {
$title = $post->post_title;
...
Related Posts:
- get_next_post() and get_previous_post() return wrong posts
- Highlight static blog page link in header
- wordpress taxonomy results
- How set featured posts using checkbox in post edit screen?
- WP_Query: Why is sticky post not first item in loop?
- Display all posts from specific categories on a page
- Skip post in loop and mixin later
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- Reverse chronology of post listing
- posts page – different lengths of excerpt
- Adding Post Counts to Menu (Nav) Programmatically?
- how to display full post with pagination on home page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- How to use alternate post layout at key points in post loop?
- Showing random content / pictures from earlier posts in a sticky post?
- Double count view in archive.php
- Group posts by year in loop
- Different style for most recent article
- Differentiate between posts and pages in search results
- Loop through all product posts?
- Restrict post navigation to current sub menu
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Display post from current category and same tag?
- Inserting custom data to the_post() during loop
- Display post category in foreach loop with category link
- Is it possible to create a form post wordpress custom navigation link?
- Displaying Latest Posts on a Page
- Display all posts that were published before full post on single.php
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- How to change the color theme per post?
- Get Image tag from content of post
- List authors with the last post title and order by last post date
- “Right Way” to make custom Loop respect reading settings inside admin panel?
- How to setup a query to output posts by groups of five?
- Only display sticky post or latest post in custom loop
- How to order posts in an arbitrary order?
- How to make a sum of all posts displayed in a loop
- Shortcodes on my website stops working after theme update [closed]
- why does wordpress ignore the post args?
- First x post with another template then the others
- Loop doesn’t show title of second post and posts thereafter
- WordPress website loads more posts than expected
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- Loop parent terms {display posts} AND loop child terms {display posts}
- How to add a class to each individual post?
- add bootstrap post slider with tabs
- How to add add more properties to WP_Post object in search results loop
- Add Blog to WP homepage Manually
- How can I remove the first two words and shorten get_the_title()
- How to show all posts by author on buddypress profile with navigation
- ACF to select posts not displaying on blog page
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- separate the post of a category by subcategory
- how to handle the loop using filling bootstrap grid structure?
- WordPress loop not working on static front page
- Optimize CPT-function with a loop
- Display specific posts on home page
- The loop starting at a certain ID
- Loop not showing first post
- Limiting the amount of posts retrieved by the loop
- Custom Post Type Single Loop Outputting Wrong Post
- Get current taxonomy and display query accordingly
- Possible?! A contextually titled back link
- Post navigation using date
- Error while excluding a post from another loop (using its ID)
- Display a specific category in a focused area of my site
- Blog posts pagination not working
- How to add a custom class attribute into code wrapper? [duplicate]
- Include Recent Post in Category
- Diffrent layout for posts [duplicate]
- get_next_post() not working with future post status
- show loop id post , only first id can read
- Excluding category from post navigation in WordPress?
- Show post excerpt
- Wp_query loop is not working as it should
- Show author bio box
- Maximum number of posts per page before affecting performance?
- Use special template for the first post in the loop
- Display post order ranking within wordpress loop
- WordPress infinite post cycle problem
- How to get all posts in gallery post format template
- Show Posts By Custom Field
- List of authors posts minus very latest
- show latest authors blog post
- Post gallery as carousel
- Showing content from WordPress ruins page CSS using WP_Query, without, content does not show
- Add something after all sticky posts in The Loop
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Latest Posts not in the right order
- Display Post by menu order
- Getting rid of the blog page entirely
- Is there a way to separate wordpress titles from their posts?
- Redirecting posts in WordPress to a specific page
- ‘posts_per_page’ => ’10’ does not show any post
- Password protection doesn’t prompt for password on pages
- When and how will php code in a user made WordPress page be executed?
- Get posts after calculating meta key
- How to remove a date from wordpress post
- wordpress pinboard theme [closed]