我正在使用“更多”快速标签来切断非付费会员的文章——比如,他们只能阅读前几段左右。我的设置工作得很好,下面是一段代码,它显示了非付费会员查看文章时要显示的内容:
} else { // They aren\'t in the paying group
global $more;
$more = 0;
the_content(\'<b>Interested in reading the rest of this article? You must be a subscriber to continue reading.</b>\');
}
?>
然而,这就是代码输出给非付费成员的内容。就我而言,该链接是不必要的:
<p> <a href="http://website.com/2013/08/news-story/#more-30729" class="more-link"><b>Interested in reading the rest of this article? You must be a subscriber to continue reading.</b></a></p>
我想知道是否可以删除链接,使其仅输出如下内容:
<p><b>Interested in reading the rest of this article? You must be a subscriber to continue reading.</b></p>
谢谢大家!
最合适的回答,由SO网友:s_ha_dum 整理而成
你需要一个过滤器the_content_more_link
.
else { // They aren\'t in the paying group
function strip_more_link($link,$linktext) {
remove_filter(\'the_content_more_link\',\'strip_more_link\',1);
return $linktext;
}
add_filter(\'the_content_more_link\',\'strip_more_link\',1,2);
global $more;
$more = 0;
the_content(\'<b>Interested in reading the rest of this article? You just be a subscriber to continue reading.</b>\');
}
在回调中写一个检查可能更有效,也更简洁,而不是在循环中添加和删除过滤器,但我不知道如何标记“付费”和“未付费”订阅者。