I’ve some data saved in put up meta that I might prefer to convert to phrases. I might prefer to create a time period in a customized taxonomy for each meta worth with a specific key.
I have to loop by ALL posts, gathering all values of the metavalue key.
I am pondering the code shall be like this, I am simply unsure the syntax precisely.
<?php
$all_posts_with_release_year = new WP_Query( array( 'post_type' => 'launch' ) );
if ( $all_posts_with_release_year->have_posts() ) {
whereas ( $all_posts_with_release_year->have_posts() ) {
$thispost=$all_posts_with_release_year->the_post();
$post_id=get_the_ID($thispost);
$release_year_value= get_metadata('launch', $post_id, 'wpcf-release-year');
//Verify to see if a taxonomy time period with that title exists.
if ($release_year_value exists as $taxonomy_term){
choose $taxonomy_term for $post_id;
}else{
create $taxonomy_term with $release_year_value;
choose $taxonomy_term for $post_id;
}
}
}
EDIT: I understand I’ve two smaller questions.
- create a taxonomy time period in a foreach loop
- choose a taxonomy time period for a put up in a foreach loop
I will see in regards to the solutions to those on the positioning and can put up a solution if I discover it, so that somebody who hasn’t damaged this larger query down into the smaller ones but can discover assist.
Thanks a lot!