Konrad Podgórski Web Developer / Software Architect

Place where I used to write about code related things. Currently umaintained.

How to change wp-content folder name in WordPress

Please keep in mind that this post was written more than 2 years ago and might be outdated.

wp-content folder contains WordPress themes and plugins, or we just call them extensions, which makes your WordPress different from others.

More or less, we all need to install some to enhance our WordPress system, just like we install softwares on our OS, but it also bring risks. Do not install any unknown extension unless you know exactly what it’s doing.We all heard about viruses and trojans, right? Although WP extensions are open source, people might not take the time to read the code line by line. On the other hand, writing secure code is a skill not every developer learns that well, so it’s possible that a useful plugin becomes a backdoor for hackers. So, be careful when you install something new.

Renaming wp-content folder

I think WP should make this step mandatory at the beginning, and it’s also helpful for hiding that your website is powered by Wordpress.

Before renaming the wp-content folder, I should mention that some plugins and themes use “wp-content” directly in the code. In such cases, these extensions should be fixed before changing wp-content name.

To check if plugins your wordpress is using are written well and compatible with WordPress API you can run FIND function plugins and themes directory for “wp-content” term. There shouldn’t be any because plugin developers should use content_url() function or WP_CONTENT_DIR constant. Every decent coding IDE offers "Find in project" function.

Open the wp-config.php file in the root folder, and add these lines before this:

    require_once ABSPATH . ‘wp-settings.php’

normally the last line

    define ('WP_CONTENT_FOLDERNAME', 'your-content');
    define ('WP_CONTENT_URL', 'http://your-domain/'.WP_CONTENT_FOLDERNAME);
    define ('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
    define ('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');

Replace ~~~your-content~~~ with a new name you like, and replace ~~~your-domain~~~ with your site domain, then, you can rename ~~~wp-content~~~ folder to the new name.

Tip for theme and plugin developers

In your code use content_url() function instead WP_CONTENT_URL, otherwise sooner or later you or some of your clients will run into problems with SSL certificate



Find this post helpful? Spread the word, thanks.