Edit pagination text in the get_the_posts_pagination function

I want to edit the screen_reader_text in link-template.php Can I do this in a theme so it wont get overwritten on update. It seems a filter is the best option but I cant find documentation on what filter to use.

Here is the code I want to change from link-template.php:

    if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    $args = wp_parse_args( $args, array(
        'mid_size'           => 1,
        'prev_text'          => _x( 'Previous', 'previous set of posts' ),
        'next_text'          => _x( 'Next', 'next set of posts' ),
        'screen_reader_text' => __( 'Posts navigation' ),
    ) );

How can I change Posts navigation to something else, via functions or another way?

2 Answers
2

You can modify screen_reader_text argument when invoking the_posts_pagination() wrapper function in your theme files:

<?php the_posts_pagination( array(
    'mid_size'  => 2,
    'prev_text' => __( 'Back', 'textdomain' ),
    'next_text' => __( 'Onward', 'textdomain' ),
    'screen_reader_text' => __( 'Whatever', 'textdomain' ),
) ); ?>

Search for the_posts_pagination in your template files, and adjust texts as you wish.

enter image description here

Leave a Comment