WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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