If i understand your question right you want a function within your theme that adds directories for the current post_type? like: uploads/post_type_name. if so here is a function for that:
function wpse_16722_type_upload_dir( $args ) {
// Get the current post_id
$id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : '' );
if( $id ) {
// Set the new path depends on current post_type
$newdir="https://wordpress.stackexchange.com/" . get_post_type( $id );
$args['path'] = str_replace( $args['subdir'], '', $args['path'] ); //remove default subdir
$args['url'] = str_replace( $args['subdir'], '', $args['url'] );
$args['subdir'] = $newdir;
$args['path'] .= $newdir;
$args['url'] .= $newdir;
}
return $args;
}
add_filter( 'upload_dir', 'wpse_16722_type_upload_dir' );
Related Posts:
- Post type specific upload folder in 3.5
- Why “Store uploads in this folder” option is not showing in Media Settings in WordPress
- wp.media add context
- Resize the WP media Uploader iFrame
- Can I stop wordpress generating media sizes
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- One step picture upload
- How to change format of file link ( Name ) when insert from media uploder
- Set different max upload size limits based on file type/extension
- Efficient way to move media folder to another folder
- How to display the maximum upload size in a WordPress single site?
- wordpress 3.6 media manager cropping timestamp
- How i can upload images to another folder?
- How to generate thumbnails when needed only?
- Media files exist in upload folder but not showing up
- Set limit to media upload?
- Save camera info as metadata on image upload?
- How to upload SVG in WordPress 4.9.8?
- Media not actually deleted on disk when click “Permanent Delete”
- Add inline uploader to plugin option page
- Could a large quantity of files in the uploads folder affect performance?
- How to call WP3.5 Media Library manager?
- Disable media library tab for non admins in uploader screen
- I want to replace a media file (pdf) with an updated version
- What are the security reasons to disallow Microsoft Word uploads?
- Prevent users from accessing mp3s in my uploads folder?
- Manipulating Media uploader
- How to set file type in wp_handle_upload?
- Create custom tab in WordPress 5 media upload
- How to Check Disk Space used by Media Library
- How to change the image size in new Media Uploader (ie use medium vs thumbnail)
- Gravity Forms – Repeatable “File Upload” field using “gform_column_input_content” filter [closed]
- Intercept request to /wp-content/uploads/random.file
- Add a YouTube or Vimeo video as a post attachment?
- Add media attachment filter to custom wp.media frame
- How to proxy local WP uploads folder to live site
- Front-end Image Upload with Preview – Is this Possible in WP?
- How to change “Publish” button text for specific page
- How to add multiple mime with same suffix in wordpress?
- Hook or function to upload media via url
- Close the media-upload thickbox right after upload is finished?
- wp_generate_attachment_metadata generates 503 Service Unavailable or 500 timeout errors
- How can I receive the image id using the media box?
- wp_enqueue_media() Will not load JS on the theme
- Placing assets for external use
- add_image_size() and uploading the exact size leaves 1×1 image in uploads
- Split up files from one big folder to multiple folders in uploads after migration
- Media Gallery Upload photo incorrect way like glitch
- WordPress uploads autocreate folder every month
- Enabling users to upload files
- Extra “uploads” added in path
- Is there a way to make my media files unsearchable?
- Error uploading images (but the images are at the server!)
- Attach media to post by media category
- Rename attachment filenames to attachment ID on upload
- WordPress Media Library showing wrong preview size?
- Restrict authors to seeing ONLY their media files
- How to edit attachment with media-upload.php?
- upload_max_filesize is set to 64 MB already but WordPress is still showing 2 MB
- How to fix the orientation of images when uploading via the WordPress Media Uploader? [closed]
- Uploading PDF files from the front-end
- WordPress Images, Header Videos and Carousel is not working live but perfect on Local Host Is It FTP? Filezilla?
- Uploaded image with non-english characters is named incorrectly in upload folder
- Anybody knows if i could upload a leaflet or openlayers3 map to wordpress webpage?
- “Trying to upload files larger than” error will not go away
- Theoretical limit of upload file size [duplicate]
- Remove Media File Items From Server That Do Not Exist in Media Library
- How to add filetype to meta value when using wp_upload_bits?
- Cropping thumbnails to specific dimensions on front end post
- Double slash in upload URLs
- Unable to upload new file as a product
- All my files are on my blog! I need sync solution
- Limit users to specific uploads
- Make inline uploader (plupload) on options page upload to a specific folder
- WordPress blog with a custom made theme hosted on heroku
- Media files not loading
- problem when uploading file by metaboxes
- Set attachment category from file name on upload
- HTTP Error WordPress on IIS uploading image
- What folder to place Large Video files?
- WordPress Upload Speed
- _d_improd_ directory in uploads breaking site images
- Organizing the Media Library for Cleanup
- Allow author to upload image via Media button without plugin
- Drag and Drop Media Not Working in Windows 10 Edge Browser
- Exclude some photos in media library
- Make custom thumbnail size image in media_sideload_image function
- Upload more than one media files with a post
- Upload file to front-end form and send as email attachment
- How to handle image resize in media_handle_sideload?
- Image uploaded in media library, can only see it when I using the WP Edit Image feature. 404 when trying to view in browser
- Host Images from Link
- Upload media error: unable to create directory (windows hosting)
- Add frontend editor with media buttons for Visitors and display only their media
- Can’t upload files 1MB+ [closed]
- WordPress Custom Fonts Problem! [closed]
- I want to customize wp.media (the wordpress admin uploader) in order to change the file name but only in video custom post type
- Updating Media Library PDF’s in bulk
- Assign multiple categories to Media Library upload
- Update media item using wordpress rest api in python