Prevent “main” WPMU site_url() being returned in functions

Since “WordPress MU is no longer under active development as a separate product“, I don’t recommend using it. Instead I recommend using the setup described in this answer. It’s highly configurable you can choose what WordPress files you want on all your WordPress sites and what you want to store separately from each other WordPress … Read more

Two (or more) parallel (sub-)TLDs that are retained when surfing the site / dynamically set the site address?

You could filter the option requests for the host. In your wp-config.php below the line … require_once ABSPATH . ‘wp-settings.php’; … add the following lines: add_filter( ‘pre_option_home’, ‘set_current_host’ ); add_filter( ‘pre_option_siteurl’, ‘set_current_host’ ); function set_current_host() { return ‘http://’ . $_SERVER[‘HTTP_HOST’]; } add_filter() is not available earlier, and you should keep such code in your wp-config.php. … Read more

What is difference between get_bloginfo(‘url’) and get_site_url()?

get_bloginfo(‘url’) calls home_url() calls get_home_url() reads option home get_bloginfo(‘wpurl’) calls site_url() calls get_site_url() reads option siteurl get_bloginfo(‘siteurl’) and get_bloginfo(‘home’) are deprecated arguments and return get_bloginfo(‘url’) (siteurl argument is documented wrong in Codex as equal to wpurl, it’s not in current code) The difference is that these two function chain to different options, which are typically … Read more

When moving a WP site, why does wp-admin redirect to old site?

If this is a single WordPress install, there are a couple database entries with your old domain. Specifically, siteurl and home within wp_options. That said, if the dev URL is temporary, you can also set the following two constants in wp-config.php: define(‘WP_HOME’, ‘http://’ . $_SERVER[‘SERVER_NAME’]); define(‘WP_SITEURL’, WP_HOME . “https://wordpress.stackexchange.com/”); Provided that WordPress is installed in … Read more

What’s the difference between home_url() and site_url()

You are asking two questions at once: What’s the difference between home_url() and site_url()? How do I get WordPress to return the URL root without the subdirectory where it’s installed? Here are the answers, and I confirmed with Andrew Nacin, a core developer of WordPress, as well as ran some server tests to confirm what … Read more