I have a custom post type and using this function to add for posts, previous and next buttons.

The problem is that within the custom post type, I have subcategories defined by a custom field category.

Is there a way to limit the previous and next post link for items only within the same category of the current post?

 function crunchify_post_navigation(){
    <div class="arrowNav">
        <div class="arrowLeft">
            <?php previous_post_link('%link', '&#8606;', FALSE); ?>
        <div class="arrowRight">
            <?php next_post_link('%link', '&#8608;', FALSE); ?>

    add_action('wp_footer', 'crunchify_post_navigation');

This function must be used within the loop.


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.