Created
December 21, 2018 06:34
-
-
Save ruucm/3c73820ba0c19fc01a9adc4f02c927e4 to your computer and use it in GitHub Desktop.
remove specific term from all posts (wordpress)
This file contains hidden or 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
<?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