• Resolved mattspace

    (@mattspace)


    Hi,

    I’m having problems with the 2017 theme not seeming to resemble normal wordpress themes as I understood them, back in the mists of history when I last tried to customise stuff.

    I’ve created a child theme, with a single.php file, and I want to restrict the previous & next nav to just posts in the same category.

    The code in the file is:

    the_post_navigation( array(
    					'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
    					'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
    				) );

    But I just flat out don’t understand this, at all.

    Would someone please just copy me back a version of this that limits the navigation to the current category? Unless it requires changes to my child theme’s functions.php, then those would be appreciated.

    I used to teach wordpress customisation to graphic design students in tertiary education, but that was back in 2010, sadly, I find some of the newer stuff baffling.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try setting ‘in_same_term’ => true in the array and it should give you the posts from just the category

    the_post_navigation( array(
    					'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
    					'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>', 'in_same_term' => true,
    				) );
    Thread Starter mattspace

    (@mattspace)

    Huzzah! Working perfectly, much appreciated ??

    cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Restrict previous & next nav to same category in single.php in 2017 theme’ is closed to new replies.