• I have articles in several sub-categories. When a visitor clicks the next link it doesn’t lead to the next post in the same category but to the next post over all. How can I make the previous and next buttons lead to post within a category?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello @tastymouse

    You can try using the following filter to achieve this requirement –

    the_post_navigation( 
    	apply_filters( 'astra_single_post_navigation',
    		array(
    			'next_text' => $next_text,
    			'prev_text' => $prev_text,
    			'in_same_term' => true,
    		)
    	)
    );

    I hope that helps. Let us know how that goes.

    Regards,
    Suman

    Thread Starter tastymouse

    (@tastymouse)

    Hi Suman,
    I have to paste this into my functions.php? Shouldn’t his be in a function? It doesn’t work in this way.

    Regards, Tom

    Hello @tastymouse

    Yes, sorry for the delay!

    You can try the following with the filter –

    add_filter('astra_single_post_navigation' , 'relevant_post_pagination' );
    
    function relevant_post_pagination() {
        return array(
            'next_text' => $next_text,
            'prev_text' => $prev_text,
            'in_same_term' => true,
       );
    }

    I hope that helps.

    Regards,
    Suman

    Thread Starter tastymouse

    (@tastymouse)

    Hi Suman, this only hides the prev-next links.
    Sorry for the late reply. I created a new website to test this.
    Regards, Tom

    Hello @tastymouse

    That’s strange.

    The code shouldn’t hide the Next and Prev pagination links.

    Can you open a ticket with us so that we can take a look and help you out accordingly? Do share the Support Topic in the ticket.

    Looking forward to hearing from you!

    Regards,
    Suman

    Thread Starter tastymouse

    (@tastymouse)

    Hi Suman,
    I opened a ticket.
    Thanks, Tom

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Next previous within a category’ is closed to new replies.