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
functions, home-url, site-url, urls
12 years
2011-06-17T13:07:10-05:00
2011-06-17T13:07:10-05:00 0 Answer
103 views
0
Answer ( 1 )
The
site_url()
andhome_url()
functions are similar and can lead to confusion in how they work.The
site_url()
function retrieves the value value forsiteurl
in thewp_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 behttp://example.com/wordpress
.The
home_url()
function retrieves the value forhome
in thewp_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 behttp://example.com
the home value should behttp://example.com
.