Underscores _s the_posts_navigation WordPress doesn’t update text

We can’t seem to get the template-tags.php the_posts_navigation function to care about basic edits at all:

if ( ! function_exists( 'the_posts_navigation' ) ) :
/**
 * Display navigation to next/previous set of posts when applicable.
 *
 * @todo Remove this function when WordPress 4.3 is released.
 */
function the_posts_navigation() {
    // Don't print empty markup if there's only one page.
    if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
        return;
    }
    ?>
    <nav class="navigation posts-navigation" role="navigation">
        <h2 class="screen-reader-text"><?php _e( 'Posts navigation', 'mytheme' ); ?></h2>
        <div class="nav-links">

            <?php if ( get_next_posts_link() ) : ?>
            <div class="nav-previous"><?php next_posts_link( __( 'Older posts!!', 'mytheme' ) ); ?></div>
            <?php endif; ?>

            <?php if ( get_previous_posts_link() ) : ?>
            <div class="nav-next"><?php previous_posts_link( __( 'Newer posts!!', 'mytheme' ) ); ?></div>
            <?php endif; ?>

        </div><!-- .nav-links -->
    </nav><!-- .navigation -->
    <?php
}
endif;

As you can see we added some exclamation marks to the posts links but WordPress could care less on the front end. It should show up on the index.php where there are plenty of posts to be seen and it stubbornly only shows “Posts navigation” as a main heading and “Older posts”.

Read More

Please help! Thank you!

Related posts

Leave a Reply

2 comments

  1. It appears that in 4.1 WordPress added the the_posts_navigation to its core functionality. Prior to that it didn’t exist and _s actually uses a function by that exact same name in template-tags.php. So now, instead of calling what used to be the custom _s function, it defaults to the WordPress version, basically ignoring the one in template-tags.php.

    To fix this I just changed the name of the _s function. Personally, I chopped off the “the” so it becomes posts_navigation in template-tags.php and then anywhere it was referenced in the theme (index.php, single.php etc.). Worked like a charm and any changes I’d made to the function in template-tags.php (adding my own arrow icons) showed right up.

  2. It appears that function in the template-tags.php file only has compatibility for WordPress versions prior to 4.1 and they are part of WordPress core.

    Using the_posts_pagination() and/or next_posts_link() / previous_posts_link() is effective enough.