home_url() vs site_url()

WordPress.com VIP platform specific

This document is for sites running on WordPress.com VIP.

Learn more

When working with domain-mapped sites on WordPress.com, home_url() and site_url() will return different values.

  • home_url() returns the primary mapped domain (e.g. vippuppies.com)
  • site_url() returns the *.wordpress.com URL (e.g. vippuppies.wordpress.com)

A few notes:

  • home_url() will only return the mapped domain on or after the init has fired. Calling it before then will return the .wordpress.com domain.
  • If you accidentally use site_url() in your templates, theme-side links will still redirect correctly to the home_url() equivalent.
  • home_url() is the preferred method, as it avoids the above redirect.

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.