0

In my single blog view, I only want to show the Prior and Next buttons within the same category the current post is in.

I thought I could just change these two lines thus (set first term to true). but that doesn't seem to ever display the buttons. Any suggestions ?

$post_prev = get_adjacent_post(false,'',true)  ? get_permalink(get_adjacent_post(false,'',true))  : false;
$post_next = get_adjacent_post(false,'',false) ? get_permalink(get_adjacent_post(false,'',false)) : false;

Thank in advance!

1

1 Answer 1

0

Add this in your functions file and it links all single posts within the same category

add_action('loop_end', 'wpsites_nav_links', 25 );
function wpsites_nav_links() {
if( !is_single() ) 
return;

previous_post_link('<span class="single-post-nav previous-post-link">%link</span>', '&lt;&lt; Previous Post in Category', TRUE);
next_post_link('<span class="single-post-nav next-post-link">%link</span>', 'Next Post in Category &gt;&gt;', TRUE);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.