Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix previous_post_link() – Only in one category

Discussion in 'Misc WordPress Requests' started by DoubleG, Mar 12, 2018.

  1. DoubleG

    Guest

    previous_post_link() – Only in one category, by DoubleG

    I am using the previous_post_link() & next_post_link() functions to navigate to previous and next posts but only want it to show/navigate to post within the same category.

    In my example the category I want to use is the “News” category which has a “category&tag_ID=16”.

    I’ve read the wordpress Codex about this function here but am still not sure how to edit the parameters within the function so it only shows previous and next posts from a specific category.

    NB. The posts on this website often use multiple categories but as explained earlier, the “news” category (16) is the one I’m looking to use.

    Currently the code I am using is as follows:

    <div class="posts_navigation_single">
    <div class="posts_prev_single">
    <?php previous_post_link(); ?>
    </div>
    <div class="posts_next_single">
    <?php next_post_link(); ?>
    </div>
    </div>

    I’d very much appreciate any help in the above subject.

    Many thanks

    previous_post_link() – Only in one category
     
    #1

Share This Page

Monarch Social Sharing Plugin