Skip to content

Instantly share code, notes, and snippets.

@ruucm
Created December 21, 2018 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruucm/3c73820ba0c19fc01a9adc4f02c927e4 to your computer and use it in GitHub Desktop.
Save ruucm/3c73820ba0c19fc01a9adc4f02c927e4 to your computer and use it in GitHub Desktop.
remove specific term from all posts (wordpress)
<?php
$args = array(
'post_type' => 'cartoon',
'tax_query' => array(
array(
'taxonomy' => 'new_or_popular',
'field' => 'term_id',
'terms' => 110,
)
),
'posts_per_page' => -1
);
$query = new WP_Query( $args );
$posts = $query->posts;
for ($i=0; $i < sizeof($posts); $i++) {
wp_remove_object_terms( $posts[$i]->ID, 'new', 'new_or_popular' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment