Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function upload_content($post_id) {
- if (get_field('type', $post_id)=='d') {
- //$designs = get_field('designs', $post_id);
- foreach ($designs as $design) {
- $design_post = array(
- 'post_title' => $design['title'],
- 'post_content' => '',
- 'post_status' => 'draft',
- 'post_type' => 'design',
- 'post_author' => 1
- );
- $photo_post_id = wp_insert_post( $design_post );
- update_field('designer', get_field('author', $post_id), $photo_post_id);
- update_field('story', $design['story'], $photo_post_id);
- update_field('design', $design['design'], $photo_post_id);
- }
- }
- if (get_field('type', $post_id)=='p') {
- $photos = get_field('photos', $post_id);
- foreach ($photos as $photo) {
- $photo_post = array(
- 'post_title' => $photo['title'],
- 'post_content' => '',
- 'post_status' => 'draft',
- 'post_type' => 'photograph',
- 'post_author' => 1
- );
- $photo_post_id = wp_insert_post( $photo_post );
- update_field('photographer', get_field('author', $post_id), $photo_post_id);
- update_field('story', $photo['story'], $photo_post_id);
- update_field('photograph', $photo['image'], $photo_post_id);
- }
- }
- if (get_field('type', $post_id)=='c') {
- $commentaries = get_field('commentaries', $post_id);
- foreach ($commentaries as $commentary) {
- $commentary_post = array(
- 'post_title' => $commentary['title'],
- 'post_content' => '',
- 'post_status' => 'draft',
- 'post_type' => 'commentary',
- 'post_author' => 1
- );
- $commentary_post_id = wp_insert_post( $commentary_post );
- update_field('commentator', get_field('author', $post_id), $commentary_post_id);
- update_field('commentary', $commentary['commentary'], $commentary_post_id);
- update_field('verse_reference', $commentary['verse_reference'], $commentary_post_id);
- }
- }
- };
- add_filter('acf/save_post', 'upload_content', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement