下划线_s the_posts_navigation WordPress不更新文本

Mr *_*ets 2 wordpress underscores-wp

我们似乎无法获得template-tags.php the_posts_navigation函数来关注基本编辑:

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;
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我们在帖子链接中添加了一些感叹号,但WordPress可能会更少关注前端.它应该出现在index.php上,其中有很多帖子可以看到,它固执地只显示"帖子导航"作为主标题和"旧帖子".

请帮忙!谢谢!

小智 6

似乎在4.1 Wordpress中将the_posts_navigation添加到其核心功能中.在此之前它并不存在,_s实际上在template-tags.php中使用完全相同名称的函数.所以现在,它不是调用曾经是自定义_s函数,而是默认为Wordpress版本,基本上忽略了template-tags.php中的版本.

为了解决这个问题,我刚刚更改了_s函数的名称.就个人而言,我切断了"the",因此它变成了template-tags.php中的posts_navigation,然后是主题中引用的任何地方(index.php,single.php等).像魅力一样工作,我对template-tags.php(添加我自己的箭头图标)中的功能所做的任何更改都显示出来了.