【问题标题】:Wordpress: Removing the "Read More" link from a custom excerpt function?Wordpress:从自定义摘录功能中删除“阅读更多”链接?
【发布时间】:2013-06-13 13:48:51
【问题描述】:

在这里,我创建了一个函数来限制特定帖子类型的摘录长度(因为我只在渐变滑块中显示该特定帖子类型的摘录),使用以下函数:

function client_excerpt($length) {
global $post;
    if ($post->post_type == 'testimonial')
         return 20;
    else
         return 55;
}
add_filter('excerpt_length', 'client_excerpt');

现在,当我在循环中调用 get_the_excerpt 为滑块输出我的 div 时,它工作得很好。但是,我不希望“阅读更多...”链接仅出现在这些摘录中。我可以阻止它们显示在我的函数中的那些特定摘录中吗?

【问题讨论】:

  • 如果您在谈论 wordpress,那么值得一提的是问题中的事实

标签: php wordpress function


【解决方案1】:

试试这个,使用excerpt_more filter:

function new_excerpt_more( $more ) {
  global $post;
  if ($post->post_type == 'testimonial'){
    return '';
  }
}
add_filter('excerpt_more', 'new_excerpt_more');

【讨论】:

  • 辛苦了!谢谢! :)
猜你喜欢
  • 1970-01-01
  • 2017-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-04
  • 2012-11-01
  • 1970-01-01
相关资源
最近更新 更多