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.

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
add comment

2 Answers

up vote 1 down vote accepted

Use site_url

<?php echo site_url(); ?>

http://codex.wordpress.org/Function_Reference/site_url

Or get_site_url

<?php echo get_site_url(); ?>

http://codex.wordpress.org/Function_Reference/get_site_url

Or even home_url

<?php echo home_url(); ?>

http://codex.wordpress.org/Function_Reference/home_url

which returns the home URL for the site.

Check the doc links for differences in available parameters.

share|improve this answer
add comment

You are looking for site_url() or home_url()

share|improve this answer
1  
You might get upvotes if you explain the difference and when to use which function. –  toscho Sep 20 '12 at 23:38
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.