尝试以下操作:
if (!wp_next_scheduled(\'update_members_types\')) {
wp_schedule_event( time(), \'daily\', \'update_members_types\' );
}
add_action ( \'update_members_types\', \'update_member_post_type\' );
function update_member_post_type() {
$args = array(
\'post_type\' => \'member\',
\'posts_per_page\' => \'1\',
\'date_query\' => array(
array(
\'after\' => strtotime( \'-24 hours\' )
)
)
);
$members = get_posts( $args );
if ( $members ) {
foreach ( $member as $members ) {
set_post_type( $member->ID, \'post\' );
}
}
}
Wordpress有一个功能,允许您更新帖子ID的帖子类型。
https://developer.wordpress.org/reference/functions/set_post_type/
请注意,cron任务不是计划在每天午夜运行,而是从初始化时起每24小时运行一次。