The upload directory and URL paths are stored in the options database. You can change them using update_option()
:
update_option( 'upload_path', ABSPATH . '/path/to/uploads' );
update_option( 'upload_path_url', site_url( '/uploads/' ) );
However, it’s best not to use this in a publiuc plugin, as it will cause numerous issues. We can instead hook into the filters that control the result of getting these options and set them to our custom paths:
function wpse_84046_upload_path( $path ) {
return '/path/to/uploads';
}
add_filter( 'pre_option_upload_path', 'wpse_84046_upload_path' );
function wpse_84046_upload_path_url( $url ) {
return site_url( '/uploads/' );
}
add_filter( 'pre_option_upload_path_url', 'wpse_84046_upload_path_url' );
Related Posts:
- Remote upload file to server B
- wp_generate_attachment_metadata is creating an empty array
- Redirect to another page using contact form 7? [closed]
- Move plugin upload folder from mywebsite.com/wp-content/uploads/pdfuploads to mywebsite.com/pdfs?
- How organize uploaded media in WP?
- Edit Yoast SEO breadcrumbs output [closed]
- What’s the best way to implement AJAX in WordPress?
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- Translating long texts with html formatting
- How to find the origin of a file upload from within wp_handle_upload?
- Plugin or method to delete uploads not in media library?
- How would I go about creating a user ranked post popularity page?
- Anonymous Postings
- Do widget options need to be escaped widget()?
- Is there any W3C compatible Share & Follow plugin?
- Does any one have Idea to get these functionalities with the plugin wp-multi-network
- How to change File URL in file uploaded to s3 compatible storage with self written plugin [closed]
- Restrict media upload size by format
- Disable woocommerce cookies and delete cart data automatically
- className not populating in custom block
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Run plugins only on certain pages
- Overide plugin files from child theme (/inc/ ) folder
- Removing included CSS file that doesn’t exist
- custom payment gateway in woocommerce failed to connect to remote api server
- Display encrypted content on my website
- Post category with counts been display like a menu
- Post custom Data value in The Events Calendar plugin [closed]
- Send reply with pre-prepared answers
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Save custom attributes of product in woocommerce
- Calling an attribute from a plugin shortcode
- Best place for short bio,image and button [closed]
- Submit page limited in time to upload image
- wp.media javascript issue with on select
- Use of Templates in a Plugin
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- Why can’t I access my Intranet LDAPS with NADI?
- External Domain on WordPress Multisite
- In the archive widget, how do I sort in between two years?
- Customization API for plugin development
- Fromcraft Plugin On click submit button [closed]
- Auto move media file to cloud
- transfer a file from one domain to another via wp
- creating a custom shop page display on archive woocommerce
- Add custom JavaScript that is a combination of CDN/uploaded files and easily-edited code?
- Setup page on first login on multisite
- polylang + category/tag custom language link
- Anspress Customization: How to show logged in user votes on a single answer?
- Custom wordpress Theme and Plugin repository
- Automatic Updates Individual Plugins Not Working
- How do I make a child theme I made POST through a 3rd party plugin?
- How create Group Blogs based on user created Groups
- How to redirect users to their profile after they successfully edit their profile
- Custom table naming/access convention for multisite: $table_prefix vs base_prefix or other?
- media page returnig to 404 in rtmedia [closed]
- Add ALT attribute to Pin It Button image to pass HTML5 validation
- date/time-picker and file upload (image) fields for custom fields (e.g. with more fields)
- Getting Theme element into plugins page editor in wp admin
- Media Upload Tab reload and change $_GET
- WordPress as web application base
- Customize The Events Calendar to Include an Option to Expand for More Events Listings
- URL rewrite of independent plugin?
- Plugin for users to create their own ads like Google Adsence
- GeoMashup plugin: how to customize cluster markers / icons? [closed]
- How do I apply style to each category of a list?
- Plugin Not Working After Being Uploaded To WordPress Plugin Repository
- Add category selection to custom post type (plugin)
- Bulk Image Upload And Rerrange Functionality
- changing posts layout in ultimate member profile plugin
- “No Add Button” for me to customize my WordPress with themes and pluggins
- Translation plugin to translate another plugins
- Login Customizer doesn’t change the background of the register form
- Inserting custom PHP script on homepage
- Creating Featured Content Boxes
- Integrating WP E-commerce plugin into custom theme
- Best practice for including plugin output in a template without using shortcode?
- Custom post types – remove default post supports through empty array?
- Basic gallery plugin suggestion [closed]
- a weird attribute on every html tag
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Is it possible for a plugin to force reading and writing of uploaded images to a database instead of to a filesystem?
- Contact Form 7 – Form name blank [closed]
- How do i get file_get_contents to work in wordpress
- Custom widget doesn’t save values from dropdown box
- Plugin Development – Functions or Hooks?
- Plugin function inside custom plugin
- WordPress as template engine
- Change the style of h1, h2, only in post entry
- Use wp_upload_dir() correctly
- Measure and limit file uploads
- adding a button to the media uploader
- Add some fileds to the wp_posts table
- Is there a function to list all uploaded images? How can I add one?
- Customizing Titles on the Fly with Code
- Disable plugin only for one post
- custom uploader in the admin area
- Free paypal cart solution [closed]
- Add filter on html tags,attributes on specific function in wordpress
- Which plugin can do horizontal scrolling of RSS feeds in WordPress [closed]