Tagged: x
-
AuthorPosts
-
September 12, 2016 at 6:01 am #1171160
mrkenneyParticipantI found the following code in the forum. I have it in the functions.php of my child theme and it’s working wonderfully. I have my blog posts divided into two parent categories. When I’m viewing a post within one of those categories is there a way to change this code so the prev next links only get a post from within the same parent category – instead of chronologically?
add_action (‘the_content’, ‘add_next_post_item_link’ );
function add_next_post_item_link ( $content ) {
if ( is_singular(‘post’) ) {
$next_name = “Next Post <i class=\”x-icon-chevron-right\”></i>”;
$prev_name = “<i class=\”x-icon-chevron-left\”></i> Previous Post”;
$next_link = get_next_post() ? ‘ID ) . ‘”>’ . $prev_name . ‘‘ : ”;
$prev_link = get_previous_post() ? ‘ID ) . ‘”>’ . $next_name . ‘‘ : ”;
$posts = ‘<div class=”wp-post-navigation-next”>’.$next_link.$prev_link.'</div>’;
return $content . $posts;
} else {
return $content;
}
}September 12, 2016 at 6:22 am #1171177
ThaiModeratorHi There,
Please find and replace these functions:
get_next_post(true) get_previous_post(true)Hope it helps 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1171160 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
