删除“阅读更多”从自定义摘录函数链接


Wordpress: Removing the "Read More" link from a custom excerpt function?

简单说一下,我创建了一个函数来限制特定post类型的摘录长度(因为我只在褪色滑块中显示该特定post类型的摘录),使用以下函数:

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

现在,当我在循环中调用get_the_摘录输出滑块的div时,效果很好。然而,我不希望"阅读更多"链接只出现在那些摘录上。我能阻止它们在我的函数中显示吗?

试试这个,使用摘录过滤器:

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