Advertisement
JeppeSigaard

Untitled

Apr 26th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. $post_title = get_the_title(); //for use as term below
  2. $post_date = get_the_date(); // may need to tweak the format, see codex ref.
  3.     if( have_rows('toc_section') ): while ( have_rows('toc_section') ) : the_row(); //checks that ACF repeater exists
  4.             $posts = get_sub_field('section_contents');
  5.                 if( $posts ):
  6.                     foreach( $posts as $post): //checks for post relations
  7.                         $postid = $post->ID;
  8.                         wp_set_object_terms( $postid, $post_title, 'eco_issues', true ); //ad a tax term
  9.                         wp_set_object_terms( $postid, 'Print', 'format', true ); //add a second tax term
  10.             //how to set the date here?
  11. // like so:
  12. $date_update = wp_update_post(array(
  13.     'ID' => $postid,
  14.     'post_date' => $post_date,
  15. ),true);
  16.  
  17.                     endforeach;
  18.                     wp_reset_postdata();
  19.                 endif;
  20.         endwhile;
  21.         wp_reset_postdata();
  22.       endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement