Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. $attachment = [
  2. 'guid' => wp_upload_dir()[ 'url' ] . '/' . basename( $path ),
  3. 'post_mime_type' => wp_check_filetype( basename( $path ), null )[ 'type' ],
  4. 'post_title' => "$mlsNum $id",
  5. 'post_content' => '',
  6. 'post_status' => 'inherit'
  7. ];
  8.  
  9. $attachmentId = wp_insert_attachment( $attachment, $path, $this->postId );
  10.  
  11. // Generate attachment metadata and create resized images.
  12. wp_update_attachment_metadata( $attachmentId, wp_generate_attachment_metadata( $attachmentId, $path ));
  13.  
  14. $gallery = get_post_gallery( $post, false );
  15. var_dump( $gallery );
  16. var_dump( $post );
  17.  
  18. wp_update_post( array(
  19. 'ID' => $attachment_id,
  20. 'post_parent' => $parent_post_id,
  21. ));
  22.  
  23. $args = array(
  24. 'post_parent' => $parent_post_id,
  25. 'post_type' => 'attachment',
  26. );
  27. $attachments = get_children( $args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement