1// Add to top of wp-config.php
2define( 'WP_HOME', 'http://example.com' );
3define( 'WP_SITEURL', 'http://example.com' );
1$url = home_url();
2echo $url; // Output: http://www.example.com
3
4$url = home_url( '/' );
5echo $url; // Output: http://www.example.com/
6
7$url = home_url( $path = '/', $scheme = 'https' );
8echo $url; // Output: https://www.example.com/
9
10$url = home_url( $path = 'example', $scheme = 'relative' );
11echo $url; // Output: /example
1//It is possible to set the site URL manually in the wp-config.php file.
2
3//Add these two lines to your wp-config.php, where “example.com” is the correct location of your site.
4
5define( 'WP_HOME', 'http://example.com' );
6define( 'WP_SITEURL', 'http://example.com' );
7
8//Important! Do not leave this code in the functions.php file. Remove them after the site is up and running again.
9
10update_option( 'siteurl', 'http://example.com' );
11update_option( 'home', 'http://example.com' );
1options table
21. siteurl
32. home
4
5######## OR ########
6
7// Add to top of wp-config.php
8define( 'WP_HOME', 'http://example.com' );
9define( 'WP_SITEURL', 'http://example.com' );
10