【问题标题】:how to remove read more after call the_content function in wordpress?在 wordpress 中调用 the_content 函数后如何删除阅读更多内容?
【发布时间】:2018-02-20 17:29:01
【问题描述】:

我想在调用 wordpress 的 the_content() 函数后删除阅读更多链接。我只想循环显示每个帖子的内容,阅读更多链接是多余的。

我尝试使用此代码,但发布内容后仍保留阅读更多链接:

add_filter( 'the_content_more_link', 'disable_more_link', 10, 2 );

function disable_more_link( $more_link, $more_link_text ) {
    return;
 }

在哪里可以找到在内容之后添加此阅读更多链接的代码?

【问题讨论】:

  • 当您致电 the_content() 时,我认为 wordpress 不会自行添加阅读更多内容。你确定你实际上没有将它明确地放在代码中吗?
  • 是的。我确定。我终于发现这个网站上安装了一个摘录插件,它负责创建这个阅读更多链接,我改变了设置,一切都修复了

标签: php wordpress


【解决方案1】:
    You can use a filter to remove the read-more link from content. I have updated your filter. Please try it, It's working fine.

    function disable_more_link( $link ) {
        $link = preg_replace( '|#more-[0-9]+|', '', '' );
        return $link;
    }
   add_filter( 'the_content_more_link', 'disable_more_link', 10, 2 );

【讨论】:

    【解决方案2】:

    More info

    function new_excerpt_more($more) {
        return '...';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    

    【讨论】:

      猜你喜欢
      • 2013-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 2019-07-17
      相关资源
      最近更新 更多