Is it possible to rename the wp-content folder dynamically? I am building a custom framework to use on themes and it would be nice to set it up where it does everything on its own.

I am using this following code right now in wp-config

define ('WP_CONTENT_DIR','/name_of_new_folder');

Can I pull the site domain through dynamically with PHP?

2 Answers 2


Don't do what seems to be possible...

You can use the possibility to change the WordPress constants WP_CONTENT_DIR and WP_CONTENT_URL in your wp-config.php.

BUT it really, really, really, really is not recommended.

Why? not recommended??

It's pretty easy: Just do a cross file search (with your IDE or for e.g. Notepad++) for wp-content and you'll find it hardcoded it many places. Some of the stuff will still work, but some wont. Yeah, I've already tried that.

  • I've read a bunch about it and it seemed the only problem people had was with plugins not working correctly? I believe this is due to bad plugin writing. Is there anything else I should look out for? I'm doing this solely for security reasons. Commented Nov 15, 2012 at 4:15
  • 1
    @ftntravis That's security through obscurity, so no real security. Actually there's no real reason to change the name. Aside from poorly coded plugins (the majority), there're things that rely on it. For example other constants like PLUGINDIR or MUPLUGINDIR (both deprecated, but in enough plugins still in use). Then there're points where you'll maybe hit edge cases in core. The MU blogs dir for example. My advice: Just don't do it. It doesn't add any value or security. It just looks different, nothing else.
    – kaiser
    Commented Nov 15, 2012 at 8:47
  • 1
    Thank you for the explanation, I appreciate it! And will definitely take it into consideration. Commented Nov 15, 2012 at 18:33

Figured it out!

define('WP_CONTENT_DIR', ABSPATH . 'name_of_new_folder');
define('WP_CONTENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/name_of_new_folder');
  • 2
    Check if your target directory is_writable() first. Usually it isn’t.
    – fuxia
    Commented Nov 11, 2012 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.