首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WORDPRESS apply_filters only主页

WORDPRESS apply_filters only主页
EN

Stack Overflow用户
提问于 2016-04-21 18:47:23
回答 1查看 110关注 0票数 1

我有一个简单的函数(在我的主题中的functions.php中),它将类添加到导航链接

代码语言:javascript
复制
   add_filter('next_posts_link_attributes', 'posts_link_attributes');
   add_filter('previous_posts_link_attributes', 'posts_link_attributes');

  function posts_link_attributes() {
     if (is_home() || is_front_page()) {
        if (current_filter() == 'previous_posts_link_attributes') {
            return 'class="prevlink ajax"';
        }
        elseif (current_filter() == 'next_posts_link_attributes') {
            return 'class="nextlink ajax"';
        }
     }
  }

我需要这只在我的主页上工作,但它不工作。有人能帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2016-04-23 04:54:41

我解决了向index.php添加过滤器的问题

代码语言:javascript
复制
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');

我不知道这是否正确,但它工作正常。会造成什么问题吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36767268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档