Tagged: x
-
AuthorPosts
-
February 4, 2017 at 12:00 pm #1357974
tey9170ParticipantHi! I’m currently running WordPress 4.7.2, Version 4.6.4 of X Theme. http://froglation.xyz
Is there a way to limit the posts navigation to the posts in each category?
I currently have this code added to my function.php file.
add_action ('the_content', 'add_next_post_item_link' ); function add_next_post_item_link ( $content ) { if ( is_singular('post') ) { $next_name = "<- Previous Chapter <i class=\"x-icon-chevron-right\"></i>"; $prev_name = "<i class=\"x-icon-chevron-left\"></i> Next Chapter -> "; $next_link = get_next_post() ? '<a style="float: right;" href="' . get_permalink( get_next_post()->ID ) . '">' . $prev_name . '</a>' : ''; $prev_link = get_previous_post() ? '<a style="float: left;" href="' . get_permalink( get_previous_post()->ID ) . '">' . $next_name . '</a>' : ''; $posts = '<div class="wp-post-navigation-next">'.$next_link.$prev_link.'</div>'; return $posts . $content . $posts; } else { return $content; } }Please advice on the modifications required.
Thanks!
February 4, 2017 at 7:24 pm #1358262
Rue NelModeratorHello There,
Thanks for writing in! You can update it and make use of this code:
add_action ('the_content', 'add_next_post_item_link' ); function add_next_post_item_link ( $content ) { if ( is_singular('post') ) { $next_name = "<- Previous Chapter <i class=\"x-icon-chevron-right\"></i>"; $prev_name = "<i class=\"x-icon-chevron-left\"></i> Next Chapter -> "; $next_link = get_next_post(true, '', 'category') ? '<a style="float: right;" href="' . get_permalink( get_next_post()->ID ) . '">' . $prev_name . '</a>' : ''; $prev_link = get_previous_post(true, '', 'category') ? '<a style="float: left;" href="' . get_permalink( get_previous_post()->ID ) . '">' . $next_name . '</a>' : ''; $posts = '<div class="wp-post-navigation-next">'.$next_link.$prev_link.'</div>'; return $posts . $content . $posts; } else { return $content; } }Please let us know if this works out for you.
February 5, 2017 at 2:20 am #1358419
tey9170ParticipantThat totally solves the problem!
Thank you so much!Keep up the good work X
February 5, 2017 at 4:50 am #1358478
ThaiModeratorYou’re most welcome 🙂
If you need anything else please let us know.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1357974 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
