Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $attachment = [
- 'guid' => wp_upload_dir()[ 'url' ] . '/' . basename( $path ),
- 'post_mime_type' => wp_check_filetype( basename( $path ), null )[ 'type' ],
- 'post_title' => "$mlsNum $id",
- 'post_content' => '',
- 'post_status' => 'inherit'
- ];
- $attachmentId = wp_insert_attachment( $attachment, $path, $this->postId );
- // Generate attachment metadata and create resized images.
- wp_update_attachment_metadata( $attachmentId, wp_generate_attachment_metadata( $attachmentId, $path ));
- $gallery = get_post_gallery( $post, false );
- var_dump( $gallery );
- var_dump( $post );
- wp_update_post( array(
- 'ID' => $attachment_id,
- 'post_parent' => $parent_post_id,
- ));
- $args = array(
- 'post_parent' => $parent_post_id,
- 'post_type' => 'attachment',
- );
- $attachments = get_children( $args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement