I use previous_post_link()
and next_post_link()
(Codex previous_post_link()/next_post_link()) outside of the Loop, with no problems.
Note that the Codex entries indicate that these functions must be used within the Loop, but IMX that isn’t true. The functions call the $post
global, and pass it to get_previous_post()
and get_next_post()
, respectively.
By the way, posts_nav_link()
is the incorrect function to use in the single-post context, anyway. It is intended for navigation of archive index pages, not of single posts.
Related Posts:
- connect last post with first post
- Can’t get the previous and next posts permalink
- Previous Posts Link and Next Posts Link Show All The Same Articles?
- posts_nav_link() not working on index.php
- Get date of last update outside of loop
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- If Loop has odd number of posts on last page Custom style for last post in it
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- How can I use get_permalink() outside the loop?
- Two loops by pre_get_post on same page
- How to check for specific content in comments in the loop
- Why we use if with while loop?
- Problem the_permalink
- Sort Posts By Category?
- Can’t access login screen, wp-login.php 404’s
- Create static front-page with 3-5 recent posts
- Customize WooCommerce Product Images (Placement and size) [closed]
- get latest 5 posts and a specific post and sort in a specific order
- How to check if a post exist?
- Query posts if meta key starts with
- 3 Posts in Loop, Show Stickies First
- Loop within a loop (Again) for template
- How to use current_post to open a new unordered list every five posts
- Rating system and changing the loop
- Pagination for multiple loops
- Ajax Button to load more Posts into a timeline
- How to target thumbnails of the first post in the loop
- Infinite Scroll on a loop?
- Problem getting current post tags to show in a widget
- Post classes in the loop are being changed in certain themes
- Exclude page name from loop
- Include multiple page ids in loop
- “Call to a member function have_posts() on array” error on have_posts();
- How to exclude or filter password protected posts when using next_post_link() previous_post_link
- How to append a query string to pagination?
- For each loop on every word in post
- Display name of taxonomy once
- Displaying the first, second, and third posts from a category in separate slides
- Get the image src and href data from posts
- Sending mail not working correctly
- Call wp-blog-header.php header without performing a wp_query
- Display post formats differently on index.php (loop in function)
- How to output thumbnail twice in a loop
- Frontpage pagination by week
- Integrating WordPress with Your Website
- Multiple instances of Featured Image Thumbnail As A Background On Homepage
- Altering “posts_per_page” for defaut loop
- Why doesn’t ‘continue’ work in page?
- Display more than 10 posts on author.php file
- Accessing the Posts page Content
- How to use this $tax_selection variable in this custom loop?
- Display all categories as plain text
- Query post & loop problem.
- Exclude current post ID from loop in sidepbar.php
- loop inside a loop : search for posts in the same category
- How do i create a loop that list and divide posts into months?
- List page is showing 404
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Duplicated tag in loop
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Loop two different category WP_Query
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Transient not working for external data
- adding tax_query to $query_string
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- Remove posts_orderby filter then add it back in
- the_title() Returns the page title instead of the post
- WP update_post_meta link loop
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- How to add excerpt in loop in Twenty Eleven theme?
- show posts from one category with comments only
- Exclude Authors based off date of last post
- How to implement template file and the loop
- Show only posts from todays date [duplicate]
- I need to update the post query? [closed]
- Multiple loop with pagination in same page
- Why did my most recent article fall behind an older one on my site?
- wp_mail sending only once inside foreach loop
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop