If you have accidentaly (or stupidly 🙂 ) changed the WordPress Address of your blog to an incorrect value, you’ll find out that you can no longer access the admin console to change it back. To fix it you have two options:
- Temporary PHP change
- Direct database change
Temporary PHP change
For this option, you will temporarily hardcode the correct wordpress address in your template and then remove it after correcting the address in the admin page.
Add the following near the top (i.e. in a new line after the first ‘
<?php‘) of the functions.php file:
Of course, you would replace http://example.com/wordpress with your actual wordpress url.
Go to the admin URL of your blog, set the WordPress address (URL), and save the changes.
Remove the code you added in Step 1.
Direct database change
Log in to your mysql database server. If you do not know the username and password, you can find them in the wp-config.php file in your wordpress installation.
Run the following SQL:
update wp_options set option_value='http://example.com/wordpress' where option_name='siteurl';
Again, you would replace http://example.com/wordpress with your actual wordpress url.