【问题标题】:Update WordPress Post Excerpt programmatically以编程方式更新 WordPress 帖子摘录
【发布时间】:2020-03-07 16:40:14
【问题描述】:

我正在寻找一个可以更新已发布的 WordPress 帖子摘录的功能。函数wp_update_post() 不会更新摘录。我研究过的其他函数,例如 the_excerpt(),仅用于获取摘录而不是设置摘录。

如何在 WordPress 中更新已发布帖子的摘录?

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    wp_update_post() 应该是使用的选择。

    您可以定位 $args 中的 post_excerpt 来处理帖子摘录。

    一个(未经测试,但应该可以工作)示例:

    $the_post = array(
          'ID'           => 37,//the ID of the Post
          'post_excerpt' => 'This is the updated excerpt.',
      );
    wp_update_post( $the_post );
    

    这是一个非常不动态的例子,但应该给出一个关于如何做的想法。

    【讨论】:

      猜你喜欢
      • 2019-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多