WordPress developer, consultant, nerd

I need to change my WordPress address and site address fields but they are disabled…now what?

If you are reading this, you are likely in a position where you are unable to edit the WordPress Address and Site Address fields in your WordPress admin;

If you haven’t dealt with this scenario before, it can be frustrating, but the root of this little problem lies in the wp-config.php file. It’s actually possible to set these values using PHP constants, as per the following example;

// Somewhere in wp-config.php…

// …

define( 'WP_HOME', 'http://mysite.com/wp' );
define( 'WP_SITEURL', 'http://mysite.com' );

/* That's all, stop editing! Happy blogging. */

// …

When these constants are set, the WordPress admin settings are disabled.

Why would someone do this?

Setting the constants has a few benefits;

  1. The most obvious advantage is to prevent people from tampering with this critical setting. If you don’t know what you’re up to, changing these could definitely bring your site offline.
  2. Using the constants does mean WordPress doesn’t need to query the database for the data – a negligible performance gain, so not a great reason to use them.
  3. By using these constants, we can have greater control over environmental differences. i.e; my local development site has WordPress in a /wp directory alongside the /wp-content directory, but the live site follows a different structure. By keeping these settings out of the database, I mitigate the possibility of killing my live site when I push the database to production.
  4. These constants make it much easier to move a site to a different domain, as we don’t need to do any searching/replacing on the database to get the new site working.

I’d rather use the admin settings…how can I enable them again?

Simple, just find the definition of these two constants in your wp-config.php file and comment them out. The result should look something like the following;

// Somewhere in wp-config.php…

// …

// define( 'WP_HOME', 'http://mysite.com/wp' );
// define( 'WP_SITEURL', 'http://mysite.com' );

/* That's all, stop editing! Happy blogging. */

// …

Just be prepared for the possibility of your site going offline if the current values in your database aren’t correct. If this happens, you need to change the values in your wp_options table…or just work directly with the constants.