Change WordPress default upload directory – Learn WordPress from a to z

Tutorials 0 lượt xem

There will be many different reasons why users want to change the default WordPress upload directory.

In terms of performance, being able to host images on a subdomain also makes backups more efficient. Changing the directory can also change the URL structure and organization for media files.

Prior to WordPress 3.5, you could change the upload directory path from the Settings menu in the backend, but this is no longer possible. But don’t worry, today I will guide you. Let’s get started!

Change default upload directory

Open  the wp-config.php file of your website, located in the root directory, and add the following code:

define('UPLOADS', 'wp-content/myimages');<div><span>1</span></div>

Make sure you add this code before the line:

require_once(ABSPATH.’wp-settings.php’);<div><span>1</span></div>

If the folder doesn’t already exist, WordPress will automatically create it as long as the wp-content folder is writable. Otherwise, you can manually create the folder via FTP, cPanel, etc.
Change default upload directory
Alternatively, you can also change the arrangement of the upload process. When you open the uploads folder, you’ll notice the files are sorted by month and year. You can change so that all media files are stored in one folder. Go to “Settings” > “Media” and uncheck “Sort files by folder based on year, month”.
Not only does it make your URLs simpler, but it also makes it easier to see all your files in one place instead of having to sort through folders by month and year.

Epilogue

You see, changing the default WordPress upload directory is extremely simple. I hope this article will satisfy your needs.

If you found this article useful, you can follow the  WordPress Tips section  and follow Facebook for more new knowledge.

Bài viết liên quan