You’re doing it twice – media_handle_upload is a wrapper for wp_handle_upload.
Just use the former like so:
require_once ABSPATH . 'wp-admin/includes/file.php';
$id = media_handle_upload(
'custom_upload',
$post->ID,
array(), // Attachment post data overrides, WordPress will do all the grunt work by default
array(
'test_form' => false,
'action' => 'editpost',
)
);
if ( ! is_wp_error( $id ) )
update_post_meta( $post->ID, 'custom_upload', $id );
Related Posts:
- Media library – Limit images to custom post type
- Creating a metabox to upload multiple images, Ignoring The Featured Image
- How to hide CPT files from media library programmatically
- Add metabox with media uploader in a custom post type [duplicate]
- How do I add media to a custom post type?
- How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page
- How do I organize photos for multiple galleries?
- Delete all associated media when custom post type removed
- Remove fields on media uploader for custom page type – not working for “From Computer” or “From Url” tabs?
- Duplicate Custom Header Functionality into the post edit screen
- how to get URL of media uploaded to WordPress via media_handle_sideload()
- Hide editor while keeping add media button in custom post type
- File sharing platform for user contributions? [closed]
- Cannot upload featured image to a custom post type
- Custom Attachment Type
- Save data is post using php front end
- Attaching more than 1 parent (Post) to a media file
- Custom post type Featured Image popup not working
- Detach WordPress Media Files In Bulk
- get all posts from a custom post type
- Set post date before 1970
- Single loop for wp_query and wp_user_query
- query multiple taxonomies
- wp_set_object_terms() is not replacing term, but creating a new one
- Custom Post Type, WP_Query and ‘orderby’
- Create an archive page for custom taxonomies
- Using custom field as custom post title
- Grab 5 latest posts from custom post type ‘announcements’
- List custom post types in dropdown
- Pagination Doesn’t Work
- filter search result with custom post type meta key
- When you create a custom post type, does that also create capabilities for editing/deleting that post type automatically?
- Numeric pagination custom post type
- Categories under custom post types doesn’t show properly
- Cleanest way to code “Custom Write Panels/Meta Boxes”?
- Add an A-Z menu at the top of A-Z listing code
- get a list of posts from Custom Taxonomy
- Trying to manage templates on a blog with lots of custom taxonomies
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- Having trouble with custom date field for CPT query (WordPress)
- How to retrieve custom field types for all posts in WordPress/PHP?
- Need functionality with all post list available at edit.php
- Add custom capabilities to existing custom post type
- Custom post type and taxonomy permalinks – Structure
- Custom Post Type Post have a Child `Page` Post Type Post
- pre_get_posts on custom post type
- Add a label to the editor?
- How to get the post type from a category id?
- Custom Post Type won’t Register
- How to duplicate fields in custom post types?
- Send email button in custom post type backend
- add category name to permalinks on product page /category-name/product-name
- create parent post using wp_insert_post
- Get image post ID in media upload
- Turn on and off custom post type from admin?
- Exclude pages in archives results
- create a new page from a custom post type similar to an authors page
- Several post types on WP Query by tag and taxonomy
- Can multiple authors be assigned on a single custom post?
- How to display custom post in archive section of the wordpress page?
- Displaying Custom Taxonomies From Multiple Custom Post Types
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Fields for different parts of a page
- Plugin fatal error
- wp_insert_post sometimes fails after API call
- Which Template Page Should I Use?
- CRUD operations in wordpress
- wp_insert_post wrong post type [closed]
- WordPress Picks Up Wrong Template for Custom Post Type Archive Page
- Archive-posttype.php isn’t loaded
- List of all entries of custom-post-type: Add year-parameter?
- Attaching a Custom Taxonomy to Posts?
- custom post type problem
- Reordering admin columns for CPT with custom taxonomy and an added custom field
- The Difference Between Categories and Tags and Taxonomies and Terms
- wp_editor for custom post type doesn’t save value
- Display registerd taxonomy in admin dashboard
- Shortcode / WP_Query in post changes context
- Cant’ Display Custom Post Type Title Base on Tax Terms
- How to achieve a multi-taxomony layout with posts?
- Displaying all posts by category and showing content on click
- Custom post type and custom taxonomy key lenght & query performance
- How to make “single post” permalink maintain it’s sub-page structure
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- check_admin_referer not working in custom meta box for custom post type
- Custom permalink with custom taxonomies for custom post type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- Getting wrong ID
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- show custom taxonomies in hierarchy
- query_post causes the posts to be loaded twice on load more posts
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- Using pagination with specific custom post type [duplicate]
- WordPress multi-query not returning as expected
- Display Custom Post Type in Custom Taxonomy URL
- Page that ‘subscribes’ to multiple categories
- List custom taxonomy terms
- Title- Custom taxonomy by using get_term
- Assign Default Taxonomy to Post When Created