Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/224bc221dad52addf1764437a6c7a867 to your computer and use it in GitHub Desktop.
Save propertyhive/224bc221dad52addf1764437a6c7a867 to your computer and use it in GitHub Desktop.
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