• Dear Astra theme help team!

    I am trying to find a solution to define posts navigation within the same category only, found some code lines that I can use:

    $next_post = get_next_post(true);
    $prev_post = get_previous_post(true);

    BUT I am very new to this and don’t know WHERE and HOW to apply the code? I am using Astra theme (if this is relevant).

    Is there a way within the Astra theme that I can do?

    Many thanks!

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

Viewing 1 replies (of 1 total)
  • Hi @irenagluck,

    I don’t think that the code you have will work. However, you can try.

    And about how to add the code, you can add the code to the functions.php file of the child theme. This doc will tell you more about that.

    Apart from that, if your code is not working, please try the following instead

    add_filter( 'astra_single_post_navigation', 'ast_post_navigation' );
    function ast_post_navigation () {
    	$arr = array(
    		'next_text' => '%title',
    		'prev_text' => '%title',
    		'in_same_term' => true,
    	);
        return $arr;
    }

    I hope it will help.

    Kind regards,
    Herman ??

Viewing 1 replies (of 1 total)
  • The topic ‘Next and Prev posts navigation within the same category – Astra theme’ is closed to new replies.