2015-02-09 12 views
2

我们似乎无法得到模板tags.php the_posts_navigation功能关心基本的编辑都:下划线_s the_posts_navigation WordPress的不更新文本

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; 

正如你可以看到,我们增加了一些感叹号标记到帖子的链接,但WordPress可能不太关心前端。它应该显示在index.php上,其中有很多帖子可以看到,它固执地只显示“Posts navigation”作为主标题和“旧帖子”。

请帮忙!谢谢!

回答

0

看起来,template-tags.php文件中的函数只对4.1之前的WordPress版本具有兼容性,它们是WordPress核心的一部分。

使用the_posts_pagination()和/或next_posts_link()/ previous_posts_link()足够有效。

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中的函数所做的任何更改(添加我自己的箭头图标)显示正确。