Archived topic
Rename previous and next links on single blog post
7 replies · Started by Tesco on January 14, 2022
Hi,
I'm trying to rename the '<' and '>' arrows in single blog posts to: '«« previous blog post' and 'next blog post »»'
add_filter( 'generate_previous_link_text', function() {
return '«« previous blog post';
} );
add_filter( 'generate_next_link_text', function() {
return 'next blog post »»';
} );
I'm using the code above on my child theme functions but is not working…
Note: Child theme is correctly implemented and there is several functions and filters functioning from there.
Please help!
Hi there,
Would you consider using this method?
https://docs.generatepress.com/article/block-element-post-navigation/
Let me know :)
Maybe... But why is this filter not working for me?
Ideally I would prefer to use a simple filter on functions.php and styling as I want
Hi there,
can you share a link to where its 'not' working ?
here it is!
Try this:
add_filter( 'generate_post_navigation_args', function( $args ) {
if ( is_single() ) {
$args['previous_format'] = '<div class="nav-previous"><span class="prev" title="' . esc_attr__( '«« previous blog post', 'generatepress' ) . '">%link</span></div>';
$args['next_format'] = '<div class="nav-next"><span class="next" title="' . esc_attr__( 'next blog post »»', 'generatepress' ) . '">%link</span></div>';
}
return $args;
} );
Works!
Thanks!
Glad to hear that