【发布时间】:2020-03-07 16:40:14
【问题描述】:
我正在寻找一个可以更新已发布的 WordPress 帖子摘录的功能。函数wp_update_post() 不会更新摘录。我研究过的其他函数,例如 the_excerpt(),仅用于获取摘录而不是设置摘录。
如何在 WordPress 中更新已发布帖子的摘录?
【问题讨论】:
我正在寻找一个可以更新已发布的 WordPress 帖子摘录的功能。函数wp_update_post() 不会更新摘录。我研究过的其他函数,例如 the_excerpt(),仅用于获取摘录而不是设置摘录。
如何在 WordPress 中更新已发布帖子的摘录?
【问题讨论】:
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 );
这是一个非常不动态的例子,但应该给出一个关于如何做的想法。
【讨论】: