• I have three blogs on my site, https://www.katiesonger.com, and I’m using categories to separate them. (www.katiesonger.com/category/writing is one category, https://www.katiesonger.com/category/politics is another, etc.) On each of these three category blogs, I’d like the next/previous post buttons to point to the next/previous post in the SAME category, rather than to the next/previous post across ALL categories.

    I’ve found many queries about this, and the answers all say that I need to work with the code “next_post_link” and “prev_post_link”, adding the argument “in_same_term” somewhere in the code. I’m new to coding, but I did create a child theme, and I’ve found the Loop code in index.php–Wordpress’s documentation seems to say that the code should be placed somewhere there (here’s their documentation). I’m still not sure, though, where to place the new code… Can you help me? Or is there some easier way to do this in Blog Way? Thanks very much!

    • This topic was modified 4 years, 11 months ago by katie.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hello Katie,

    Greetings of the day!

    It might be helpful.

    <?php next_post_link( '%link', 'Next post in category', TRUE ); ?>
    <?php previous_post_link('%link', 'Previous in category', TRUE); ?>

    Please refer this link for more details.

    Please let me know in case you need more help!

    Thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘Next/previous post by category?’ is closed to new replies.