Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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>
share|improve this answer
    
Hey thanks Chip, I just figured it out and yes you are right. I forgot the damn echo. –  marcup Apr 13 '13 at 20:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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