Rename the wp-content folder

Posted on 30th September, 2015 Leave a Comment

First select the wp-content folder and give it your chosen name (assets, stuff, content…) For this example I’m going to name it stuff.

With that done, open your wp-config.php file and add the four lines below, above the require_once(ABSPATH . 'wp-settings.php'); line at the bottom of your file.

define ('NEW_CONTENT_FOLDERNAME', 'stuff'); /* Change stuff to the name you gave your wp-content folder */
define ('WP_CONTENT_DIR', ABSPATH . NEW_CONTENT_FOLDERNAME);
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_CONTENT_URL', WP_SITEURL . NEW_CONTENT_FOLDERNAME);

With this done all files uploaded will use the new “stuff folder”, but wait…

If you have images already added to the site, then you’ll want to replace the old link to the files with the new one.

Add this to your functions.php.

define('WP_UPLOADSURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
add_filter( 'the_content', function( $upload_dir_uri ){
	return str_replace( WP_UPLOADSURL . '/wp-content/', WP_UPLOADSURL . '/stuff/', $upload_dir_uri ); /* Again Change stuff */
});

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]