search
HomeCMS TutorialWordPressHow to change the default media upload location in WordPress

Do you want to change the default media upload location in WordPress?

Moving media files to other folders can improve website speed and performance and help you create backups faster. It also gives you the freedom to organize your files in the way that suits you best.

In this article, we will show you how to change the default media upload location in WordPress.

How to change the default media upload location in WordPress

Why change the default media upload location?

By default, WordPress stores all images and other media files in the /wp-content/uploads/ folder.

In this folder, you will find subfolders for different years and months. For example, all files you uploaded in January 2023 will be stored in https://example.com/wp-content/uploads/2023/01/.

How to change the default media upload location in WordPress

This default structure works for most WordPress blogs and websites. However, sometimes you may want to change the location where WordPress stores files. For example, you can host images on a subdomain because this can improve your WordPress performance.

Moving media files to other folders can also help you create backups faster.

That being said, let's take a look at how to gradually change the default media upload location in WordPress.

Change the default media upload location in WordPress

To change the media directory, you need to add code snippets to your WordPress website. That is, you may need to create a backup of your website before making any changes.

Once done, you need to connect to your site using an FTP client such as FileZilla. If you haven't used FTP before, please refer to our beginner's guide on how to upload files to WordPress using FTP.

After connecting with FTP, simply create a new folder to store the media files. Make a note of the exact folder name, as you will need it in the next step.

Next, you need to add code snippets to WordPress. Typically, WordPress tutorials will ask you to add custom code to the theme's functions.php file.

The biggest problem is that even a tiny bug in a custom code snippet can break your WordPress website and even make it inaccessible. Also, the next time you update your WordPress theme, you will lose all your custom code.

Therefore, we recommend using WPCode. WPCode is the most popular code snippet plugin that allows you to add custom CSS, PHP, HTML, and more without putting your WordPress website at risk.

The first thing you need to do is install and activate the free WPCode plugin on your website. For more details, see our step-by-step guide on how to install WordPress plug-ins.

Once activated, go to Code Snippets in the WordPress dashboard » Add Snippets.

On this screen, hover over Add your own custom code snippet and click it when Use code snippet appears.

How to change the default media upload location in WordPress

First, enter the title of the code snippet. This is for your reference only, so you can use whatever you want.

When finished, open the Code Type drop-down list and select PHP Fragment.

How to change the default media upload location in WordPress

You can now paste the following into the code editor:

How to change the default media upload location in WordPress

When you are done, scroll to the top of the screen and click the Inactive switch to make it appear Active.

You can then go ahead and click Save Fragment to make the code take effect.

How to change the default media upload location in WordPress

Now that you have changed the media upload location, you may want to change how the files are organized in this new folder.

By default, WordPress stores all media files in month and year folders. If you want all files to be saved in the same folder, go to Settings » Media .

You can now uncheck the "Organize my uploads..." box and click "Save changes".

How to change the default media upload location in WordPress

WordPress now uploads all your media files to the same folder. To view these files, simply connect to your site using the FTP client and open the folder of your choice.

For more information on troubleshooting WordPress upload issues, see our guide on how to fix common image problems in WordPress.

We hope this article helps you change the default media upload location in WordPress. You may also want to check out our guide for the most common WordPress errors and how to fix them, as well as the best SEO plugins and tools you should use.

The above is the detailed content of How to change the default media upload location in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does WordPress's plugin ecosystem enhance its CMS capabilities?How does WordPress's plugin ecosystem enhance its CMS capabilities?May 14, 2025 am 12:20 AM

WordPresspluginssignificantlyenhanceitsCMScapabilitiesbyofferingcustomizationandfunctionality.1)Over50,000pluginsallowuserstotailortheirsiteforSEO,e-commerce,andsecurity.2)Pluginscanextendcorefeatures,likeaddingcustomposttypes.3)However,theycancausec

Is WordPress suitable for e-commerce?Is WordPress suitable for e-commerce?May 13, 2025 am 12:05 AM

Yes, WordPress is very suitable for e-commerce. 1) With the WooCommerce plugin, WordPress can quickly become a fully functional online store. 2) Pay attention to performance optimization and security, and regular updates and use of caches and security plug-ins are the key. 3) WordPress provides a wealth of customization options to improve user experience and significantly optimize SEO.

How to add your WordPress site in Yandex Webmaster ToolsHow to add your WordPress site in Yandex Webmaster ToolsMay 12, 2025 pm 09:06 PM

Do you want to connect your website to Yandex Webmaster Tools? Webmaster tools such as Google Search Console, Bing and Yandex can help you optimize your website, monitor traffic, manage robots.txt, check for website errors, and more. In this article, we will share how to add your WordPress website to the Yandex Webmaster Tool to monitor your search engine traffic. What is Yandex? Yandex is a popular search engine based in Russia, similar to Google and Bing. You can excel in Yandex

How to fix HTTP image upload errors in WordPress (simple)How to fix HTTP image upload errors in WordPress (simple)May 12, 2025 pm 09:03 PM

Do you need to fix HTTP image upload errors in WordPress? This error can be particularly frustrating when you create content in WordPress. This usually happens when you upload images or other files to your CMS using the built-in WordPress media library. In this article, we will show you how to easily fix HTTP image upload errors in WordPress. What is the reason for HTTP errors during WordPress media uploading? When you try to upload files to Wo using WordPress media uploader

How to fix the issue where adding media buttons don't work in WordPressHow to fix the issue where adding media buttons don't work in WordPressMay 12, 2025 pm 09:00 PM

Recently, one of our readers reported that the Add Media button on their WordPress site suddenly stopped working. This classic editor problem does not show any errors or warnings, which makes the user unaware why their "Add Media" button does not work. In this article, we will show you how to easily fix the Add Media button in WordPress that doesn't work. What causes WordPress "Add Media" button to stop working? If you are still using the old classic WordPress editor, the Add Media button allows you to insert images, videos, and more into your blog post.

How to set, get and delete WordPress cookies (like a professional)How to set, get and delete WordPress cookies (like a professional)May 12, 2025 pm 08:57 PM

Do you want to know how to use cookies on your WordPress website? Cookies are useful tools for storing temporary information in users’ browsers. You can use this information to enhance the user experience through personalization and behavioral targeting. In this ultimate guide, we will show you how to set, get, and delete WordPresscookies like a professional. Note: This is an advanced tutorial. It requires you to be proficient in HTML, CSS, WordPress websites and PHP. What are cookies? Cookies are created and stored when users visit websites.

How to Fix WordPress 429 Too Many Request ErrorsHow to Fix WordPress 429 Too Many Request ErrorsMay 12, 2025 pm 08:54 PM

Do you see the "429 too many requests" error on your WordPress website? This error message means that the user is sending too many HTTP requests to the server of your website. This error can be very frustrating because it is difficult to find out what causes the error. In this article, we will show you how to easily fix the "WordPress429TooManyRequests" error. What causes too many requests for WordPress429? The most common cause of the "429TooManyRequests" error is that the user, bot, or script attempts to go to the website

How scalable is WordPress as a CMS for large websites?How scalable is WordPress as a CMS for large websites?May 12, 2025 am 12:08 AM

WordPresscanhandlelargewebsiteswithcarefulplanningandoptimization.1)Usecachingtoreduceserverload.2)Optimizeyourdatabaseregularly.3)ImplementaCDNtodistributecontent.4)Vetpluginsandthemestoavoidconflicts.5)ConsidermanagedWordPresshostingforenhancedperf

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools