Convert attribute woocommerce terms (taxonomy terms) in custom post type

NEED
I have a list of terms of attributes in woocommerce, specifically WRITERS: list of writers name.
I want to convert writers name in posts of a custom post type, WRITERS. The terms of attribute woocommerce are around 2000.
I would like to automate the insertion.

IDEA
Use wp_insert_post and create a loop that inserts the name of the term of the taxonomy as the title of the post. Is it possible?

function convert_attribute_post_type () {
$terms = get_terms(“pa_writers”);
foreach ( $terms as $term ) :

wp_insert_post(array(‘post_title’=>’$term->name’, ‘post_type’=>’writers’, ‘post_content’=>’text’));

endforeach;
}

Is it possible?

Read more here:: Convert attribute woocommerce terms (taxonomy terms) in custom post type

Leave a Reply

Your email address will not be published. Required fields are marked *