Auto Draft Specific Categories Posts after a certain number of Days
I want to put posts from two categories to automatically draft after the number of days like 90 Days from the date of Publish and I created a function with the help of some codes in other forums, but its not working.
Post type = property
Taxonomy = property-ad-type
Targeted Property Ad Type Categories with IDs = (free-text-only-ad - ID:108), (photo-ad - ID: 107)
Targeted Number of Days = (90Days from the date of Publish)
I added this function
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);
}
}
}
}
Topic wp-cron custom-taxonomy draft custom-post-types Wordpress
Category Web