Does anyone have an idea why my home_url() function gets the URL of the current page instead of the site address? (The site runs locally using MAMP.)

1 Answer 1


Since you didn't post actual code in your question, I can only speculate. However, a common problem is that, when calling home_url(), it is not echoed. The value of the function is returned, rather than echoed, so it must be explicitly echoed by the code.

I'm guessing you have something like this:

<a href="<?php home_url(); ?>">Home</a>

Which renders like so:

<a href="">Home</a>

...and would explain why the linked URL is the current page, rather than the expected URL for the site front page.

If so, change it to this:

<a href="<?php echo home_url(); ?>">Home</a>
  • Hey thanks Chip, I just figured it out and yes you are right. I forgot the damn echo.
    – Marc Wiest
    Apr 13, 2013 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.