我想把两个类别的帖子在发布后的90天内自动起草,我在其他论坛的一些代码的帮助下创建了一个功能,但它不起作用。
岗位类型=property<分类法=property-ad-type
ID=(free-text-only-ad - ID:108), (photo-ad - ID: 107)目标天数=(90Days from the date of Publish)
我添加了这个函数
wp_schedule_event(time(), \'daily\', \'property_status_update\');
//add_action(\'init\',\'property_ad_status_update\');
function property_status_update() {
$the_query = get_posts( \'post_type=property\' );
foreach($the_query as $single_post) {
$id=$single_post->ID;
$post_date=get_post_modified;
$taxonomy = \'property-ad-type\';
if($taxonomy = \'108\' || $taxonomy = \'107\'){
$today=date(\'Y-m-d\', strtotime(\'-24 days\'));
if($post_date = $today){
$update_post = array(
\'ID\' => $id,
\'post_status\' => \'draft\',
\'post_type\' => \'property\' );
wp_update_post($update_post);
}
}
}
}