function wpse_59621_mimes_filter( $mimes ) {
return array( 'pdf' => 'application/pdf' );
}
function wpse_59621_delay_mimes_filter( $value ) {
if ( isset( $_REQUEST['post_id'] ) && get_post_type( $_REQUEST['post_id'] ) === 'my_post_type' )
add_filter( 'upload_mimes', 'wpse_59621_mimes_filter' );
else
remove_filter( 'upload_mimes', 'wpse_59621_mimes_filter' );
return $value;
}
add_filter( 'wp_handle_upload_prefilter', 'wpse_59621_delay_mimes_filter' );
Let us know how it goes – this is untested, but I’m confident!
Related Posts:
- Submit post and upload image from front-end
- How to disable generation of default image sizes for some custom post types?
- How can I bulk upload images and automatically create posts for each one at the same time?
- Use a separate upload folder for custom post attachment upload
- Handling front-end file uploads, considering safety and ease of use
- Hide “Add media”, HTML editor from TinyMCE
- Creating a metabox to upload multiple images, Ignoring The Featured Image
- Set custom upload path for custom post type only?
- How to hide CPT files from media library programmatically
- Add metabox with media uploader in a custom post type [duplicate]
- Remove tabs from media uploader for a CPT
- Removing Image Sizes for Custom Post Type
- How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page
- Image size filtering in Media uploader according to custom post type
- Rename the insert button in media upload window
- Change upload_dir folder at a certain cpt but cant change back
- wp is not defined error using wp.media to create a custom image uploader
- Upload Image from Front End and Resize
- MP3 Manager for WordPress
- How to rename image at uploading on specific plugin or post-type in WordPress
- Cannot attach media when capabilities added to custom post type
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- 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
- Force documents to appear in Featured Image dialogue
- how to get URL of media uploaded to WordPress via media_handle_sideload()
- Display users uploaded files as posts
- Get image post ID in media upload
- WordPress 3.5 Media Uploader – Only allow 1 upload and certain file types
- Add a button or image button that calls wp functions in the wp-admin
- How to Create an Image Upload Box for Custom Posts?
- How to get the upcoming post ID from front end?
- Custom Post Type Video – Online/Offline
- How to update post meta on uploaded image from a custom form?
- frontend image post uploader
- Checking if $_FILE isset for an array of file upload metaboxes
- How to: wordpress job listing and candidates details
- How to add multiple images to a custom post type without plugin [closed]
- Why won’t this jQuery code work?
- Create a custom post type for a photo post
- File sharing platform for user contributions? [closed]
- Cannot upload featured image to a custom post type
- Invalid file type when using wp_upload_bits to upload PDF to a custom post type
- Insert into post button missing on custom post type
- Why this didn’t work if i use get_the_ID(), but works if i pass the numeric id
- Make it impossible to save a custom post type with both video and image selected?
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Create Custom Post Type PDF File (Like Media) Then Add Searchable Custom Fields
- Custom Upload Directory for Custom Post Types
- Custom post type media upload error with custom user role
- adding a shortcode into a custom post type
- Custom Post Type to Upload Images
- Allow authors to create article image
- Changing upload directory and migrating old attachments
- Can I assign a template to a custom post type?
- How to remove “read more” link from custom post type excerpt
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Can you make a custom metabox field be required to save a new post?
- Best Way to Create a List of Musician Gigs in WordPress
- Filter a custom field based on selection of another custom field (ACF) [closed]
- Posts in Multiple Columns and Rows with one single loop
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Parent drop-down not appearing for custom post type
- How to add custom fields to admin UI and REST API response?
- Display custom post on home page based on a metabox selection
- How to filter the taxonomy terms based on another taxonomy term
- List custom post types in metabox
- Custom post query with multiple fields with number values. Totalisation needed
- How to add content to a post tied to an Archive template specifically for a custom post type
- Custom post type and category link together
- Custom Meta Title for Custom Post Type
- Display custom post type posts first, then default posts
- Custom post type posts don’t show in archive widget
- Should I create Custom Page Types?
- Custom Meta fields Update hook?
- Displaying custom post types in front end
- How to add section above header for custom post types
- Check if custom post is a parent?
- A faster way to query custom post types with multiple conditions?
- add_query_arg() for custom post type on all visible links
- Redirecting search to specific templates with $_GET[“post_type”]
- Custom post type filter is being applied to all of my posts
- How to query custom post types with multiple keys?
- CPT permalinks Rewrite
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- What is the best way to structure posts for the same event happening in different years?
- How to create a Child & Siblings menu for a custom post type?
- Automatic Set Category For A Custom Post Type
- Show parent category and subcategory once in while loop
- Allow duplicate permalinks slugs for custom posts by different authors
- Create an administation subpage containing posts in a certain category
- Custom 404 redirect for a luddite
- How can you use a page for a custom post type?
- Custom post type and google visibility
- How to create default taxonomy term for a custom post type? [duplicate]
- title tag for custom post type remove taxonomy name from title tag
- Posts without featured image using other post’s featured image
- Create page using same slug as custom post type
- Pagination not working
- Issues on saving data from CPT select metabox