How to Change Wp-content Folder Name in WordPress - Tips, How To, Computer, Android, iOS and More

Saturday, June 9, 2018

How to Change Wp-content Folder Name in WordPress


In WordPress all your themes, plugins, and uploaded images are stored in the “wp-content” folder. In fact, the URLs of images, stylesheets, etc., contain the folder name “wp-content” in them, which makes it easy for anyone to know you are using WordPress. If you think the default folder name is not intuitive or if you would like to customize the name to meet your personal taste, you can easily rename the folder. Here’s how to do it.

Things to Know Beforehand

Changing or renaming the “wp-content” folder is easy. All you have to do is add a few lines of code. However, there are some things you should consider before renaming the folder.


  • If your website or blog is already live and serving content, be prepared for at least a couple minutes of downtime.
  • Renaming the “wp-content” folder doesn’t necessarily improve security or hide the fact that you are using WordPress.
  • All the installed plugins and themes will be deactivated in the process. You have to manually activate them after renaming the folder.
  • Sometimes deactivated themes may lose their settings. Back up settings before proceeding.
  • After renaming the folder, some plugins may not work as they should. The reason being is that the offending plugins may not be following the WordPress guidelines and have a hardcoded “wp-content” folder name.
  • On an established site or blog the old URLs are not automatically redirected to the new URL. You have to manually do that using plugins like Redirection, so I recommend you think twice before making this change on a live site.

Rename the “wp-content” Folder

Note: When doing changes to a live WordPress site, create a full backup. If anything goes wrong or the result is not desirable, you can restore the site to its known good state.

First, open your favorite FTP client, log into your site and rename the “wp-content” folder located in the root directory. In my case I renamed it to “content.” You can rename it anything you want like assets, resources, core, files, etc. Just make sure that you are not using any spaces or other obscure characters.

As soon as you rename this folder, the backend Plugins page will show errors and the front end breaks, too.

To fix that we need to tell WordPress that we have changed the folder name.

Open the “wp-config.php” file in the root folder. Add the below code snippet above the require_once(ABSPATH . 'wp-settings.php'); line. Don’t forget to replace “Folder_Name” with the actual folder name.

//Rename wp-content folder
define ('WP_CONTENT_FOLDERNAME', 'Folder_Name');

This is how it looks once you add it.

After that we need to define the new directory path and URL. To do that, add the below code above the require_once(ABSPATH . 'wp-settings.php'); line.

//Define new directory path
define ('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME);
 
//Define new directory URL
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_CONTENT_URL', WP_SITEURL . WP_CONTENT_FOLDERNAME);


Once you’ve done that, your site should be up and running without any errors. Like I said before, all your plugins and themes will be deactivated. You have to activate them manually. If needed, you might also have to re-configure the plugins, themes, and widgets.

Source: maketecheasier.com

Post Bottom Ad