Support » Theme: Astra » Post titles instead of “Next Post” and “Previous Post”?

  • Resolved zhanna

    (@zhanna)


    I would like the “Next Post” and “Previous Post” links to be the titles of the next and previous posts, rather than just text strings that don’t change. How can I do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • emranemranx

    (@emranemranx)

    Hi Zhanna,

    You will need to customize the theme for this. You can also consult with a developer.

    Thanks!

    Nikhil Chavan

    (@nikschavan)

    Hello,

    Astra has a filter that can be used to change the default strings to actual post names for next and previous links.

    Just add this snippet to your child theme –

    
    function your_prefix_next_previous_post_titles() {
    	return array(
    		'next_text' => get_the_title( get_next_post() ) . ' <span class="ast-right-arrow">&rarr;</span>',
    		'prev_text' => '<span class="ast-left-arrow">&larr;</span> ' . get_the_title( get_previous_post() ),
    	);
    }
    
    add_filter( 'astra_single_post_navigation', 'your_prefix_next_previous_post_titles' );
    
    Thread Starter zhanna

    (@zhanna)

    Thank you! I had just figured out a different (but similar) way to do it by overriding astra_single_post_navigation_markup(); yours is more elegant. I learned a lot, though! Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post titles instead of “Next Post” and “Previous Post”?’ is closed to new replies.