Loop Post Navigation Links
Template tags (for use in single.php) to create post navigation loop (previous to first post is last post; next/after last post is first post).
The facts
- Rating
- 5★ from 12
- Active installs
- 500+
- Price
- Free
- Last updated
- 27 Aug 2020
- Added
- Jul 2009
- Requires WP
- 4.9
- Tested up to
- WP 5.5.20
- Downloads
- 22,787
Our analysis
AI-assistedLoop Post Navigation Links is a WordPress plugin that allows for a circular navigation of posts on a website. It provides two template tags that enable users to link to the next and previous posts in a loop, meaning that the last post links back to the first post and the first post links to the last post.
This plugin is suitable for sites that want to create a seamless reading experience, such as portfolios or blogs, by ensuring that visitors can continuously navigate through posts without hitting a dead end.
Best for: This plugin is best for bloggers or portfolio sites looking to enhance post navigation.
What it does well
- ✓Creates a circular navigation loop for posts
- ✓Includes four template tags for flexibility
- ✓Useful for portfolios and continuous reading
Where it falls short
- •Limited information on additional features or customisation options
Verdict
Loop Post Navigation Links provides a straightforward solution for circular post navigation, making it a practical choice for specific types of websites.
From the developer
Scott Reilly's own description of Loop Post Navigation Links, lightly tidied.
This plugin provides two template tags for use in single.php to create a post navigation loop, whereby previous to the first post is the last post, and after the last post is first post. Basically, when you’re on the last post and you click to go to the next post, the link takes you to the first post. Likewise, if you’re on the first post and click to go to the previous post, the link takes you to the last post.
The function c2c_next_or_loop_post_link() is identical to WordPress’s next_post_link() in every way except when called on the last post in the navigation sequence, in which case it links back to the first post in the navigation sequence.
The function c2c_previous_or_loop_post_link() is identical to WordPress’s previous_post_link() in every way except when called on the first post in the navigation sequence, in which case it links back to the last post in the navigation sequence.
Useful for providing a looping link of posts, such as for a portfolio, or to continually present pertinent posts for visitors to continue reading.
If you are interested in getting the post itself and not just a link to the post, you can use the c2c_get_next_or_loop_post() and c2c_get_previous_or_loop_post() functions. If you just want the URL to the post, you can use c2c_get_next_or_loop_post_url() and c2c_get_previous_or_loop_post_url().
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Template Tags
The plugin provides four template tags for use in your single-post theme templates.
Functions
-
function c2c_next_or_loop_post_link( $format='%link »', $link='%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Like WordPress’snext_post_link(), this function displays a link to the next chronological post (among all published posts, those in the same category, or those not in certain categories). Unlinknext_post_link(), when on the last post in the sequence this function will link back to the first post in the sequence, creating a circular loop. -
function c2c_get_next_or_loop_post_link( $format='%link »', $link='%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Like `c2c_next_or_loop_post_link(), but returns the value without echoing it. -
function c2c_previous_or_loop_post_link( $format='« %link', $link='%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Like WordPress’sprevious_post_link(), this function displays a link to the previous chronological post (among all published posts, those in the same category, or those not in certain categories). Unlinkprevious_post_link(), when on the first post in the sequence this function will link to the last post in the sequence, creating a circular loop. -
function c2c_get_previous_or_loop_post_link( $format='« %link', $link='%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Like `c2c_get_previous_or_loop_post_link(), but returns the value without echoing it. -
function c2c_get_next_or_loop_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Like WordPress’sget_adjacent_post()when used to find the next post, except when on the last post in the sequence this function will return the first post in the sequence, creating a circular loop. -
function c2c_get_previous_or_loop_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Like WordPress’sget_adjacent_post()when used to find the previous post, except when on the first post in the sequence this function will return the last post in the sequence, creating a circular loop. -
function c2c_get_next_or_loop_post_url( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Returns the URL for the next post or the post at the beginning of the series. -
function c2c_get_previous_or_loop_post_url( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
Returns the URL for the previous post or the post at the end of the series.
Arguments
-
$format
(optional) A percent-substitution string indicating the format of the entire output string. Use%linkto represent the next/previous post being linked, or%titleto represent the title of the next/previous post. -
$link
(optional) A percent-substitution string indicating the format of the link itself that gets created for the next/previous post. Use%linkto represent the next/previous post being linked, or%titleto represent the title of the next/previous post. -
$in_same_term
(optional) A boolean value (either true or false) indicating if the next/previous post should be in the current post’s same taxonomy term. -
$excluded_terms
(optional) An array or comma-separated string of category or term IDs to which posts cannot belong. -
$taxonomy
(optional) Taxonomy, if $in_same_term is true. Default ‘category’.
Examples
<div class="loop-navigation">
<div class="alignleft"><?php c2c_previous_or_loop_post_link(); ?></div>
<div class="alignright"><?php c2c_next_or_loop_post_link(); ?></div>
</div><h3>Hooks</h3>
The plugin is further customizable via eleven hooks. Typically, code making use of hooks should ideally be put into a mu-plugin, a site-specific plugin (which is beyond the scope of this readme to explain), or in theme template files. Many of these filters are likely only of interest to advanced users able to code.
c2c_previous_or_loop_post_link_output, c2c_next_or_loop_post_link_output (filters)