WordPress.org

Ready to get started?Download WordPress

Plugin Directory

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).

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's next_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). Unlink next_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's previous_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). Unlink previous_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.

Arguments

  • $format (optional) A percent-substitution string indicating the format of the entire output string. Use %link to represent the next/previous post being linked, or %title to 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 %link to represent the next/previous post being linked, or %title to 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.

Examples

<div class="navigation">
    <div class="alignleft"><?php c2c_previous_or_loop_post_link(); ?></div>
    <div class="alignright"><?php c2c_next_or_loop_post_link(); ?></div>
</div>

Filters

The plugin is further customizable via eight hooks. Typically, this type of customization would be put into your active theme's functions.php file or used by another plugin.

c2c_previous_or_loop_post_link_output, c2c_next_or_loop_post_link_output (filters)

The 'c2c_previous_or_loop_post_link_output' and 'c2c_next_or_loop_post_link_output' filters allow you to customize the link markup generated for previous and next looping links, respectively.

Example:

<?php // Prepend "Prev:" to previous link markup. function my_custom_previous_or_loop_link_output( $output, $format, $link, $post, $in_same_term, $excluded_terms, $taxonomy ) { return 'Prev: ' . $output; } add_filter( 'c2c_previous_or_loop_post_link_output', 'my_custom_previous_or_loop_link_output', 10, 4 ); ?>

c2c_previous_or_loop_post_link_get, c2c_next_or_loop_post_link_get (filters)

The 'c2c_previous_or_loop_post_link_get' and 'c2c_next_or_loop_post_link_get' filters allow you to customize the link markups generated for previous and next looping links, respectively, but in the non-echoing functions.

c2c_previous_or_loop_post_link, c2c_next_or_loop_post_link (actions), c2c_get_previous_or_loop_post_link, c2c_get_next_or_loop_post_link (filters),

The 'c2c_previous_or_loop_post_link' and 'c2c_next_or_loop_post_link' actions allow you to use an alternative approach to safely invoke c2c_previous_or_loop_post_link() and c2c_next_or_loop_post_link(), respectively, in such a way that if the plugin were deactivated or deleted, then your calls to the functions won't cause errors in your site. The 'c2c_get_previous_or_loop_post_link' and 'c2c_get_next_or_loop_post_link' filters do the same for the non-echoing c2c_previous_or_loop_post_link() and c2c_next_or_loop_post_link().

Arguments:

  • Same as for for c2c_previous_or_loop_post_link() and c2c_next_or_loop_post_link()

Example:

Instead of:

<?php echo c2c_previous_or_loop_post_link( '<span class="prev-or-loop-link">&laquo; %link</span>' ); ?>

Do:

<?php echo do_action( 'c2c_previous_or_loop_post_link', '<span class="prev-or-loop-link">&laquo; %link</span>' ); ?>

Requires: 3.6 or higher
Compatible up to: 3.8.3
Last Updated: 2013-12-31
Downloads: 7,307

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
0,1,0