3

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');
define('WP_CONTENT_URL','http://example.com/name_of_new_folder');

Can I pull the site domain through dynamically with PHP?

2 Answers 2

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.

3
  • 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. 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
    Nov 15, 2012 at 8:47
  • 1
    Thank you for the explanation, I appreciate it! And will definitely take it into consideration. Nov 15, 2012 at 18:33
1

Figured it out!

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

Your Answer

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

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