24 Nov 2021

how to rename wp-content folder in WordPress

How to Rename WP-Content Folder

If you do not want your user content folder to be named as WP-Content, you can change the name of the folder and ask WordPress to pick your user data from the new folder.

WordPress allows you to define the name of the content folder with the help of WP_CONTENT_FOLDERNAME symbol.

Step 1: Edit the WP-Config.php file

Step 2: Open and Edit the WP-Config.php file to add the below line

define( 'WP_CONTENT_FOLDERNAME', ‘new_directry_name’ );
You can add the code before the ABSPATH variable declaration in WP-Config.php.

Once you add this to your WP-Config.php, WordPress will treat the new directory name as your content folder.

Remember this is just a rename, so your new content directory should be in the same location as WP-Content folder.

Step 3: Change ‘new_directory_name’ to the name you want for your content folder.

Step 4: Upload WP-Config.php file back to your server.

***

How to replace the WP-Content Folder

If you want to replace the wp-content folder rather than renaming it in the same place, you need to use the below mention method.

WordPress comes with two symbols, WP_CONTENT_DIR and WP_CONTENT_URL, which allows you to define your content directory and content URL structure.

Step 1: Download the WP-Config.php file

Step 2: Open and Edit the WP-Config.php file to add the below lines

define( 'WP_CONTENT_DIR', ‘new_directry_local_path’ );
define( 'WP_CONTENT_URL', 'http://new_directry_url' );

WP_CONTENT_DIR will tell WordPress to use the specified directory as a content directory rather than WP-Content directory.

You also need to change the WP_CONTENT_URL, so that the URL also points to correct place. It is crucial for your themes, plugins, and attachments to work correctly.

Like in rename method, you can add these line before the ABSPATH variable declarations.


Make sure there are no forward slashes (/) at the end of URL and Directory.

Step 3: Change new_directory_local_path and http://new_directory_url to your local path and URL.

Step 4: Upload WP-Config.php file back to your server.

Once you add these lines, you will see all your uploaded themes, plugins and images will start using the new directory rather than a WP-Content folder.

So, here is how you can rename or replace the WP-Content folder to provide more security to your WordPress site. This will help in making sure that hackers scripts can’t directly run on your installation, which will avoid many automated attacks on your WordPress site. So go ahead and secure your WordPress installation.

No comments:

Post a Comment