【问题标题】:How to add Multiple Custom Excerpt Lengths In WordPress如何在 WordPress 中添加多个自定义摘录长度
【发布时间】:2018-04-19 17:48:15
【问题描述】:

默认情况下,WordPress 摘录设置为 55 个单词。我想获取多个摘录,每个都返回不同的数值,这样我就可以获得博客模板的简短摘录,其他帖子类型循环的自定义单词摘录。如何在 wordpress 中做到这一点?

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    您可以使用以下函数更改内容长度

    // for get_the_excerpt()
    echo wp_trim_words( get_the_excerpt(), 40, '...' );
    
    // for get_the_content()
    echo wp_trim_words( get_the_content(), 40, '...' );
    

    更多信息在这里https://developer.wordpress.org/reference/functions/wp_trim_words/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-04
      • 2017-02-26
      • 2018-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多