Forcing a term/taxonomy on all posts of CPT
Try this: function custom_set_term_to_post(){ $args = array( ‘post_type’ => ‘post’, ); $all_posts = get_posts(); foreach ($all_posts as $key => $post) { $tag_name=”post_tag”; // required tag name $term_list = wp_get_post_terms($post->ID, $tag_name, array(“fields” => “ids”)); if (!empty($term_list)) { // there is already tags; need not do anything continue; } $tag = array( 23 ); // required tag … Read more