Skip to content

Instantly share code, notes, and snippets.

@aydinjavadly
Last active October 30, 2021 21:41
Show Gist options
  • Save aydinjavadly/74aad5094c2b7d121ebce5705f82874b to your computer and use it in GitHub Desktop.
Save aydinjavadly/74aad5094c2b7d121ebce5705f82874b to your computer and use it in GitHub Desktop.
WordPress - Change "wp-content" folder name. Change "themes" folder name. Change "plugins" folder name. Change "mu-plugins" folder name. Change "uploads" folder name. Changing the Site URL.
<?php
/**
* File: wp-config.php
*
* 1. Changing the Site URL
* 2. Change "wp-content" folder name
* 3. Change "themes" folder name
* 4. Change "plugins" folder name
* 5. Change "mu-plugins" folder name
* 6. Change "uploads" folder name
*
* NOTE:
- 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.
- You cannot move the themes folder because its path is hardcoded relative to the wp-content folder.
*
* Default structure:
* - wp-content
- plugins
- themes
- mu-plugins
- uploads
*
* After this hook:
* - public (rename old wp-content)
- app (rename old plugins)
- front (create new theme folder and add your new theme to this folder)
- themes (*don't touch this folder)
- root (rename old mu-plugins)
- storage (rename old uploads)
*
*/
/** 1. Changing the Site URL */
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/' ); // Website URL
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' ); // WordPress URL
/** 2. Change "wp-content" folder name */
define( 'WP_CONTENT_FOLDERNAME', 'public');
define( 'WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME );
define( 'WP_CONTENT_URL', WP_SITEURL . '/' . WP_CONTENT_FOLDERNAME );
/** 3. Change "themes" folder name */
$theme_root = WP_CONTENT_DIR . '/front';
/** 4. Change "plugins" folder name */
define( 'WP_PLUGINS_FOLDERNAME', 'app');
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/' . WP_PLUGINS_FOLDERNAME );
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/' . WP_PLUGINS_FOLDERNAME );
/** 5. Change "mu-plugins" folder name */
define( 'WPMU_PLUGINS_FOLDERNAME', 'root');
define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/' . WPMU_PLUGINS_FOLDERNAME );
define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/' . WPMU_PLUGINS_FOLDERNAME );
/** 6. Change "uploads" folder name */
define ( 'WP_UPLOADS_FOLDERNAME', 'storage' );
define ( 'UPLOADS', WP_CONTENT_FOLDERNAME . '/' . WP_UPLOADS_FOLDERNAME );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment