Improvement to copy all terms associated with post types
-
Hi,
in your function duplicate_term I suggest to include something similar to:
So you can “link” the term with his relative posts.
/* NIKI: clona anche collegamenti tags => post */
$posts_with_term_args = array(
‘post_type’ => get_post_types(),
‘posts_per_page’ => -1,
‘tax_query’ => array(
array(
‘taxonomy’ => $taxonomy,
‘field’ => ‘id’,
‘terms’ => $term_id
)
)
);
$posts_with_term = get_posts( $posts_with_term_args );
foreach ( $posts_with_term as $postwterm ) {
wp_set_object_terms($postwterm->ID, $new_term[‘term_id’], $taxonomy, true);
}
wp_reset_query();
- The topic ‘Improvement to copy all terms associated with post types’ is closed to new replies.