yes, it because wordpress use the server address from database get_option('siteurl')
and get_option('home')
, so if you access the wordpress from IP Address the assets (js and css) will still loaded from localhost/wp/
that mean from 127.0.0.1
not the 10.0.0.1
the simple way to get dynamic url for your wordpress is defining the site_url and home_url on wp-config.php with function that parse the request and get the correct root url for your wordpress
try to add this script below the
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . "https://wordpress.stackexchange.com/");
/**
* get home url from absolute path
* @return string url to main site
* [email protected]
*/
function get_dynamic_home_url(){
$base_dir = ABSPATH; // Absolute path
$doc_root = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']);
$base_url = preg_replace("!^${doc_root}!", '', $base_dir);
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$port = $_SERVER['SERVER_PORT'];
$disp_port = ($protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443) ? '' : ":$port";
$domain = $_SERVER['SERVER_NAME'];
$home_url = "${protocol}://${domain}${disp_port}${base_url}";
return $home_url;
}
$url = get_dynamic_home_url();
define('WP_SITEURL', $url);
define('WP_HOME', $url);