Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $post_title = get_the_title(); //for use as term below
- $post_date = get_the_date(); // may need to tweak the format, see codex ref.
- if( have_rows('toc_section') ): while ( have_rows('toc_section') ) : the_row(); //checks that ACF repeater exists
- $posts = get_sub_field('section_contents');
- if( $posts ):
- foreach( $posts as $post): //checks for post relations
- $postid = $post->ID;
- wp_set_object_terms( $postid, $post_title, 'eco_issues', true ); //ad a tax term
- wp_set_object_terms( $postid, 'Print', 'format', true ); //add a second tax term
- //how to set the date here?
- // like so:
- $date_update = wp_update_post(array(
- 'ID' => $postid,
- 'post_date' => $post_date,
- ),true);
- endforeach;
- wp_reset_postdata();
- endif;
- endwhile;
- wp_reset_postdata();
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement