Modify the default WP content / uploads upload file path of WordPress website

Generally, the default upload path of WordPress is WP content / uploads, but some netizens think that the path is too deep and want to modify the default path or implement a custom file path. For example, some of our netizens want to set an images folder in the root directory of the website, and then upload all the pictures or other attachments to this directory. There is no way to achieve WordPress background, we need to modify the configuration code can be achieved.

if(get_ option(‘upload_ path’)==’wp-content/uploads’ || get_ option(‘upload_ path’)==null) {
update_ option(‘upload_ path’,WP_ CONTENT_ DIR.’/uploads’);

Here we can go in Functions.php Add a file, and then set the default path to be modified.

Then we can see that there is one more item in the setting media. We can customize the modification path here, or modify it to a local bound subdirectory address and an independent secondary domain name as the storage address of the image.

Related Article
WordPress displays the registration time of the login user in the frontend

When using WordPress to build a website, some users want to display the user registration time in the frontend, but Read more

WordPress adds the number of SQL queries at the bottom

An excellent woodpress theme is definitely that the less SQL consulting is used, the better. How can we see how Read more

Some WordPress articles can be seen after comments / replies

If we want to hide part of the content of the article and need the user's comments and replies to Read more

WordPress common template function reference document

Basic template filefile namedescribe style.css Theme style file index.php Home page template file header.php Header template file single.php Single article Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image