• Resolved santtumarika

    (@santtumarika)


    Hi! How can i make so that next and previous post -navigation links would show posts only from same category? I have many categories on that site but would like to have this post navigation show only posts from current category.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • for the default next/prev pages links get_the_post_navigation() or previous_post_link() / next_post_link(), they’ve all got an arg in_same_term that’d do that for you.

    Thread Starter santtumarika

    (@santtumarika)

    Hi! I did change to link-template.php in_same_term to be true (code below) but still its not working. Did i do it wrong?

    function get_previous_post( $in_same_term = true, $excluded_terms = ”, $taxonomy = ‘category’ ) {
    return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
    }

    function get_next_post( $in_same_term = true, $excluded_terms = ”, $taxonomy = ‘category’ ) {
    return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
    }

    sorry, I should of mentioned you should be editing your theme, not core WordPress files. Your theme is in poseland/wp-content/themes/oceanwp/

    It appears that your theme oceanwp has the single post navigation setup in the file partials/single/next-prev.php – however it does correctly have 'in_same_term' => true, set – which is interesting.

    It seems to be a really customizable theme and has a user option to use the TAG or the CATEGORY for next/prev, and on a default setup, it’s using the TAG by default (not the CATEGORY).

    So, to change it, open your WordPress Dashboard, go to Apperances > Customizer > Blog > Single Post, there’s an option Next/Prev Taxonomy, change it from TAG to CATEGORY and you should be set.

    Thread Starter santtumarika

    (@santtumarika)

    Thank you so much!! That really did the trick! 😀

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post page: next and previous link from same category’ is closed to new replies.