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

Question

My understanding is that site_url() returns the location where the WordPress core files are.

If my blog is hosted at http://example.com/blog then site_url() returns http://example.com/blog

But then how does home_url() differ? For me, home_url() returns the same thing: http://example.com/blog

If that’s correct, then can I get WordPress to return http://example.com/ ?

in progress 0
, , , Praveen 12 years 2011-06-17T13:07:10-05:00 0 Answer 103 views 0

Answer ( 1 )

    0
    2021-08-05T12:56:53-05:00

    The site_url() and home_url() functions are similar and can lead to confusion in how they work.

    The site_url() function retrieves the value value for siteurl in the wp_options table in your database.

    This is the URL to the WordPress core files.
    If your core files exist in a subdirectory /wordpress on your web server, the value would be http://example.com/wordpress.

    The home_url() function retrieves the value for home in the wp_options table in your database.

    This is the address you want people to visit to view your WordPress web site.

    If your WordPress core files exist in /wordpress, but you want your web site URL to be http://example.com the home value should be http://example.com.

Leave an answer

Browse
Browse