0

i tried to make my previous/next to move only for one category,but i can't seen to make it work... http://pastebin.com/kDECBeKE this is a pastebin of my template-tags.php where i have my next_post_link code. Here's a short version of the code :

 <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'sixteen' ) . '</span> %title' ); ?>
            <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'sixteen' ) . '</span>' ); ?>
0

You should be able to just use the default get_next_post_link with $in_same_term set to true. Have you tried that?


Instead of your

<?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'sixteen' ) . '</span>' ); ?>

try this

<?php next_post_link ( '%link &rarr;', '%title', true, '', 'category' ); ?>
  • I read about that on google,sadly i'm a noob in coding so i can only do basic stuff,i don't know how to set it to true because i can't really find $in_same_term,should i add it in the code ? If so,where exactly ? Thanks – galikshine Mar 21 '15 at 14:35
  • Check the edit. – jimihenrik Mar 21 '15 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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