I am looking for a function that can update the excerpts of already published WordPress posts. The function wp_update_post()
does not update the excerpts. Other functions that I looked into like the_excerpt()
are only for getting the excerpt instead of setting it.
How can I update the excerpts of published posts in WordPress?
wp_update_post() should be the choice to use.
You can target the post_excerpt
, in the $args, to address the Posts Excerpt.
An (untested, but should work) example:
$the_post = array(
'ID' => 37,//the ID of the Post
'post_excerpt' => 'This is the updated excerpt.',
);
wp_update_post( $the_post );
This is a very undynamic example but should give an idea about how to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With