is_home doesn’t affect content

You need to is is_front_page() instead of is_home(). is_home() actually refers to the blog page (or the home page if you have it set to show latest posts). is_front_page() refers to the page (regardless of whether it is a static page or a latest posts feed) that sits on the front of your site.

What is the purpose of storing `siteurl` in database?

Since you mention multiple environments you can manually define the site URL within your wp-config.php file define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/path/to/wordpress’); define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/path/to/wordpress’); Keep in mind that it will override what you have set in your options table. As detailed in the documentation: Setting this value in wp-config.php overrides the … Read more

Logout redirects to a broken page(home URL is omitted)

Found the answer. It is a bug in WordPress v5.2.3 affecting WordPress in Windows environments. Caused by backslashes in Windows paths that aren’t stripped correctly Details here: https://core.trac.wordpress.org/ticket/47980 I have tried the patch suggested and can confirm it solves the problem. replace: $location = “https://wordpress.stackexchange.com/” . ltrim( $path . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/” ) . $location; with … Read more

Using Multiple Queries of “home_url” vs. Calling a Variable Multiple Times

If you look at the source for the home_url() function, you’ll note a small series of function calls eventually invoking get_option(). As explained in this WPSE Answer, the get_option() function is cached, meaning that if an option’s value is already in memory, get_option() returns that value instead of querying the database again. As a result, … Read more

Why does WordPress rely on an fully qualified site_url with a 15-step plan for moving a site?

This question has been discussed several times on the WordPress Hackers email list, I’d recommend Googling something like wp-hackers absolute relative to get an overview of the various lively debates that have taken place over the years. Personally I use the searchreplacedb2 script whenever I migrate a database between URLs, e.g. from live to local/test/dev.