【发布时间】:2021-10-29 11:27:39
【问题描述】:
我有这样的自定义字段自动更新帖子内容的功能:
function update_content(){
$mycustomfield = get_post_meta( get_the_ID(), 'customfield', true);
$post = array();
$post['ID'] = get_the_ID();
$post['post_content' ] = $mycustomfield ;
$post['post_title' ] = $mycustomfield ;
// Update the post into the database
wp_update_post( $post );
我们只更新自定义字段来制作内容。目前,我们在 save_post 钩子上手动启动这个功能,但是文章太多了,我们现在需要一个 cron 来自动化这个功能:每小时处理 4 个帖子,直到所有帖子都完成,然后重新开始。
如何制作,谢谢
【问题讨论】: