Created
May 22, 2024 03:03
-
-
Save propertyhive/224bc221dad52addf1764437a6c7a867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_just_listed_flag() { | |
$args = array( | |
'post_type' => 'property', | |
'posts_per_page' => -1, | |
'post_status' => 'publish', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'marketing_flag', | |
'field' => 'slug', | |
'terms' => 'just-listed', | |
), | |
), | |
'date_query' => array( | |
array( | |
'column' => 'post_date_gmt', | |
'before' => '1 month ago', | |
), | |
), | |
); | |
$query = new WP_Query($args); | |
if ($query->have_posts()) { | |
while ($query->have_posts()) { | |
$query->the_post(); | |
$post_id = get_the_ID(); | |
wp_remove_object_terms($post_id, 'just-listed', 'marketing_flag'); | |
} | |
} | |
wp_reset_postdata(); | |
} | |
add_action('init', 'remove_just_listed_flag'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment