Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How i can get the base URL in the wordpress? get_bloginfo('url') returns me the current URL. I just want the base URL e.g http://localhost/wpsite/ not any ?page_id=123 with it

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Use site_url

<?php echo site_url(); ?>

Or get_site_url

<?php echo get_site_url(); ?>

Or even home_url

<?php echo home_url(); ?>

which returns the home URL for the site.

Check the doc links for differences in available parameters.

share|improve this answer

You are looking for site_url() or home_url()

share|improve this answer
You might get upvotes if you explain the difference and when to use which function. – toscho Sep 20 '12 at 23:38

Your Answer


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.