Title: [Plugin: WP Single Post Navigation] Loop within category
Last modified: August 20, 2016

---

# [Plugin: WP Single Post Navigation] Loop within category

 *  [hoboscience](https://wordpress.org/support/users/hoboscience/)
 * (@hoboscience)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-single-post-navigation-loop-within-category/)
 * I know this isn’t the intention of the plugin but I would love to have only a
   forward option looping within a category. No reverse options. Is this possible?
 * Thanks
 * [http://wordpress.org/extend/plugins/wp-single-post-navigation/](http://wordpress.org/extend/plugins/wp-single-post-navigation/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [David Decker](https://wordpress.org/support/users/daveshine/)
 * (@daveshine)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-single-post-navigation-loop-within-category/#post-2646122)
 * [@hoboscience](https://wordpress.org/support/users/hoboscience/):
 * Hi there!
    Sorry for the little delay!
 * Know what, your request is just possible 🙂
 * You should add the following code to your theme/child theme’s `functions.php`
   file (please make file backup before!):
 *     ```
       add_filter( 'wpspn_next_post_link', 'custom_wpspn_next_link' );
       /**
        * WP Single Post Navigation: Add custom filters for "next post link"
        */
       function custom_wpspn_next_link() {
   
           $args = array (
               'format'                => '%link',     // Change link format (default: %link)
               'link'                  => '&laquo;',   // Change link string (default: «)
               'in_same_cat'           => TRUE,       // Apply only to same category (default: FALSE)
               'excluded_categories'   => ''           // Exclude categories (default: empty)
           );
   
           next_post_link( $args['format'], $args['link'], $args['in_same_cat'], $args['excluded_categories'] );
       }
   
       add_filter( 'wpspn_previous_post_link', 'custom_wpspn_previous_link' );
       /**
        * WP Single Post Navigation: Add custom filters for "previous post link"
        */
       function custom_wpspn_previous_link() {
   
           return NULL;
       }
       ```
   
 * It just adds only forward link and removes previous link! And it applies “only
   in category” to TRUE!
    If you want the arrow to appear on the other side you 
   only have to change the `&laquo;` in my code to `&raquo;` – all ok? 🙂
 * Hope that helps, Dave 🙂
 *  Thread Starter [hoboscience](https://wordpress.org/support/users/hoboscience/)
 * (@hoboscience)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-single-post-navigation-loop-within-category/#post-2646178)
 * Thanks for the response. That worked with one exception. I lose the forward arrow
   when I reach the final page in the category. Could this page loop back to the
   first page in the category?
 *  Plugin Author [David Decker](https://wordpress.org/support/users/daveshine/)
 * (@daveshine)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-single-post-navigation-loop-within-category/#post-2646181)
 * This is just intended default behavior provided by the core WordPress function
   that the plugin uses. The function has no paramaters for looping anything so 
   it’s just not possible. We can only hope together that they might implement something
   like that in future versions of WP…
 * I hope that helps… 🙂
    -Dave.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: WP Single Post Navigation] Loop within category’ is closed to
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-single-post-navigation_64b8f4.
   svg)
 * [WP Single Post Navigation](https://wordpress.org/plugins/wp-single-post-navigation/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-single-post-navigation/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-single-post-navigation/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-single-post-navigation/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-single-post-navigation/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-single-post-navigation/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [David Decker](https://wordpress.org/support/users/daveshine/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-single-post-navigation-loop-within-category/#post-2646181)
 * Status: not resolved