site url wordpress code example
Example 1: wordpress change site address
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );
Example 2: wp-config change url wp-config
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Example 3: home url wordpress
$url = home_url();
echo $url;
$url = home_url( '/' );
echo $url;
$url = home_url( $path = '/', $scheme = 'https' );
echo $url;
$url = home_url( $path = 'example', $scheme = 'relative' );
echo $url;
Example 4: define url wordpress
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );
update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );
Example 5: current url wordpress
global $wp;
echo home_url( $wp->request )
Example 6: change site url wordpress database
options table
1. siteurl
2. home
######## OR ########
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );