The Difference Between home_url() and site_url() WordPress Functions

WordPress ships with a lot of helper functions to speed up theme and plugin development such as the home_url() and site_url().

These two functions – home_url() and site_url() return the same value (WordPress address or URL) if WordPress hasn’t been given its own directory.

If WordPress is given its own directory, their return values will differ.

Say you installed a WordPress blog in the root folder of http://abc.com but the core WordPress files was moved to a sub-directory named wp-core.

The function home_url() will return http://abc.com and site_url() will return http://abc.com/wp-core.

See this WordPress Stack Exchange post for more details on their difference.

Keep in Mind

Using the bloginfo function, you can get the same URL return by both home_url() and site_url().

bloginfo( 'wpurl' ) is an alias of site_url()

bloginfo( 'url' ) is an alias of home_url().

Don’t miss out!
Subscribe to My Newsletter
Invalid email address