• Please help me,
    I want to change link to previous post (in single.php) from “previous post” to “previous post wihtin same category”.

    I don’t know how to do it…

Viewing 1 replies (of 1 total)
  • I was just going to ask the same question but then I found this solution:

    You need to edit the file: wp-includes/link-template.php
    There is a section called // Navigation links (row 1430 with WP 4.1)

    You need to change the variable $in_same_term from “false” to “true” in
    function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
    and in
    function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )

    So these two rows should look like this:
    function get_previous_post( $in_same_term = true, $excluded_terms = '', $taxonomy = 'category' )
    and
    function get_next_post( $in_same_term = true, $excluded_terms = '', $taxonomy = 'category' )

    This worked for me.

Viewing 1 replies (of 1 total)
  • The topic ‘Next post wihtin same category’ is closed to new replies.