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
2 Answers
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.
You are looking for site_url()
or home_url()
-
1You might get upvotes if you explain the difference and when to use which function.– fuxia ♦Sep 20, 2012 at 23:38