Update expired properties.

This commit is contained in:
Hoang Huu
2019-11-04 08:28:41 +07:00
parent 09e5f5adfc
commit 943d5e20e4
5 changed files with 252 additions and 108 deletions

View File

@@ -393,6 +393,33 @@ function opalestate_cleanup() {
}
}
wp_reset_postdata();
// Change status expired properties.
$expired_query = new WP_Query( [
'post_type' => 'opalestate_property',
'post_status' => [ 'pending', 'publish' ],
'meta_query' => [
[
'key' => OPALESTATE_PROPERTY_PREFIX . 'expired_time',
'value' => time(),
'compare' => '>=',
'type' => 'NUMERIC',
],
],
] );
if ( $expired_query->have_posts() ) {
while ( $expired_query->have_posts() ) {
$expired_query->the_post();
wp_update_post( [
'ID' => get_the_ID(),
'post_status' => 'expired',
] );
}
}
wp_reset_postdata();
}
/**