You can use the 'upload_dir'
filter
add_filter('upload_dir', 'set_upload_folder', 999);
function set_upload_folder( $upload_data ) {
// absolute dir path, must be writable by wordpress
$upload_data['basedir'] = trailingslashit(ABSPATH). '/files';
$upload_data['baseurl'] = 'http://subdomain.wptest.com/files';
$subdir = $upload_data['subdir'];
$upload_data['path'] = $upload_data['basedir'] . $subdir;
$upload_data['url'] = $upload_data['baseurl'] . $subdir;
return wp_parse_args($upload_data, $upload_data);
}
This code will works no matter if year/month subfolders option is on or off.
Note that, of course, you need to configure your DNS to point the new url to the right folder.
Related Posts:
- Images not being generated at correct size
- Custom delete option button in plugin settings
- update_options and unique filenames
- Alow users to delete uploaded images inside backend?
- Double slash in upload URLs
- How to show all available images in WP’s media library when using the Polylang plugin?
- retrieve custom image sizes from media uploader javascript object
- register_setting() vs add_option()
- Append button to WordPress Image Details modal
- How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
- How to make WordPress use new Upload Path settings in Multisite Setup
- How to set custom upload directory per user after moving content directory
- File Upload Permissions
- View content from uploaded file in editor
- Media upload – choose only one file
- Add suffix to filename of uploaded images
- WordPress cannot upload data after migration
- How to rewrite WordPress uploads folder to another folder using htaccess
- Settings API get_option best practices
- How To install AWS SDK for PHP in wordpress?
- Add fields to the WordPress media uploader
- wp_editor in front end not working
- Can’t get plugin settings page to save data
- How to safely allow user upload on CPTs?
- How to upload unknown file type?
- The Settings API – What is the purpose of default value in register_setting?
- WooCommerce Images are uploading to the server but not attaching
- Why would media_sideload_image() not work locally?
- Two settings_fields in one form
- The uploaded file exceeds the upload_max_filesize directive in php.ini
- How to get specific setting by settings_fields()?
- Media upload on WordPress changes title of image
- Upload file programmatically
- remove_accents does not seem to work (when used inside sanitize_file_name filter)
- Remove upload file types filter for admin
- Whitelisting items from custom options page
- wrong media url in wordpress
- Prevent small image sizes from being uploaded
- Front-End Social photo upload [closed]
- Protecting uploads not working
- How to upload a file from WP directory automatically?
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- Update problem with update_option() in combination with register_setting()
- Show the submitted values in the form when validation fails
- Hide images from anonymous user?
- cannot upload anything into wordpress
- Uploaded images do not show on localhost
- WordPress Drag n Drop Uploader – Single File Only
- Multi Upload In Theme Options
- How to load attachment in media library for current user?
- Why does get_dirsize return the same size?
- How To Watermark Audio
- Maximum post size?
- tb_show not showing a media upload window . custom plugin
- In the media Rest API, what is “missing_image_sizes”?
- Can I use register_settings and unregister_setting once the settings page has loaded?
- Error: The uploaded file exceeds the upload_max_filesize directive in php.ini [duplicate]
- Issue on Checkbox with Custom Option Page
- Creating a podcast directory site – how to allow user to upload “large” files?
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- get array of files in uploads dir
- Is there a way a user/member can upload a file and link it in his profile page?
- how to disable WordPress flash up-loader?
- Send an e-mail notification to custom user role when a file is uploaded to uploads folder
- Resize uploaded original images to a minimum automatically
- Settings API and ‘type’ => ‘font’
- WordPress Thumbnail compression depends on the server?
- Upload PDF and other files from the Front-End
- How to add a Reset to Defaults button with Settings API?
- Custom Text in Media Uploader in a Theme Options Page
- How to disable image thumbnails from media manager but not post media uploader?
- Call require_once form admin page with checkbox
- Certain functions are not available when executed with wp_schedule_event
- Upload image fails “upload test” on localhost
- Get uploaded video URL
- How Do I Change the File Permission For Uploaded Files in WordPress?
- WordPress media has all disappeared on wp-admin but still on the server
- The uploaded file exceeds the upload_max_filesize directive in php.ini. showing while uploading a theme
- image not display in media library and thumbnail not display in post
- How to upload .tex files in wordpress?
- Which WordPress file controls the featured image upload maximum width and height of 3000px
- Moving wp-content folder to public_html
- Using Gravity Forms to upload media into library, then attach to post
- Some images not appearing after switching from AWS S3 back to local
- Uploading a file results in attachment post, but file is missing
- Why I am not able to upload media files?
- Store uploads on an external server?
- WordPress Media manager select file button, how to prevent hiding?
- Dynamically Update Key in Associative Array When Saving Settings
- Limit number of uploaded attachments of specific context
- Set featured link not showing
- WordPress upload folder on separate server
- increase maximum upload file
- How i can upload images to another folder?
- make default upload folder year/month/day wordpress without plugin [duplicate]
- Where to adjust presets for slider options “auto rotate” (3, 5, 10, 15 seconds)? [closed]
- Display Image Upload from Contact Form 7 on Redirect Page [closed]
- media_handle_sideload() fails
- How to upload and add images to the existing post from the front-end with admin approval which is posted by other user
- Create media folder upon post publish?