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.

I am developing a plugin.

I want to know difference between

get_bloginfo('url');  

and

get_site_url();

I got same output, then what's the difference?

share|improve this question
add comment

4 Answers

up vote 8 down vote accepted
  • get_bloginfo('url') calls home_url() calls get_home_url() reads option home

  • get_bloginfo('wpurl') calls site_url() calls get_site_url() reads option siteurl

  • get_bloginfo('siteurl') and get_bloginfo('home') are deprecated arguments and return get_bloginfo('url') (siteurl argument is documented wrong in Codex as equal to wpurl, it's not in current code)

The difference is that these two function chain to different options, which are typically same.

It would be more appropriate to compare get_bloginfo('url') to get_home_url() or get_bloginfo('wpurl') to get_site_url(). Then the answer is that these functions are on different level in chain. Typically the deeper function is - the more flexible it is and the less filters output passes through.

share|improve this answer
add comment

From 'wp-includes/general-template.php'

function get_bloginfo( $show = '', $filter = 'raw' ) {

switch( $show ) {
      case 'home' : // DEPRECATED
      case 'siteurl' : // DEPRECATED
        _deprecated_argument([snipped]);
      case 'url' :
        $output = home_url();
        break;
      case 'wpurl' :
        $output = site_url();
        break;

So:

  • get_bloginfo('home'), get_bloginfo('siteurl') and get_bloginfo('url') are equivalent to calling home_url() (also note that the use of home and siteurl as get_bloginfo parameters is deprecated)
  • get_bloginfo('wpurl') is the same as calling site_url()
share|improve this answer
    
get_bloginfo('siteurl') is long deprecated and currently is same as get_bloginfo('url') (home_url()). It would make more sense for it to equal get_bloginfo('wpurl') (site_url()) but for some reason it doesn't. I see that Codex says otherwise, well - code is different from documentation. Source. –  Rarst May 2 '11 at 13:35
    
ok...interesting and confusing. editing my answer having looked at the code! –  anu May 2 '11 at 14:54
add comment

Check out the parameters over at Codex:

get_site_url / get_bloginfo

share|improve this answer
    
I am looking for specific difference between the two –  I-M-JM May 2 '11 at 8:51
    
checking the codex would allow you to see specific differences between the two. –  anu May 2 '11 at 12:41
add comment

IIRC, the primary difference between home_url()/get_site_url() and their get_bloginfo() analogs is that home_url()/get_site_url() return the proper http/https scheme, while get_bloginfo() doesn't.

share|improve this answer
    
Incorrect, get_bloginfo() simply calls site_url()/home_url() functions and will return proper scheme just as they do. –  Rarst May 2 '11 at 13:40
    
Oh neat! Looks like that changed since the last time I looked at general-template.php. :) –  Chip Bennett May 2 '11 at 14:16
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.