Support » Fixing WordPress » get_bloginfo or get_option

  • Resolved huggie


    Can someone let me know the difference between the following two snippets of code, and which one I should be using and why? I know that ‘wpurl’ has replaced the deprecated ‘siteurl’, but these two appear (According to the Codex) to do exactly the same thing.

    $wp_address = get_option('wpurl');
    and this one
    $wp_address = get_bloginfo('wpurl');


Viewing 3 replies - 1 through 3 (of 3 total)
  • It kind of doesn’t matter as in most cases, get_bloginfo is just a wrapper for get_option, but in the case of get_option('wpurl'); nothing will be returned.

    Internally the function get_bloginfo('wpurl'); uses this code:

    case 'wpurl' :
       $output = get_option('siteurl');

    So you would need to use
    $wp_address = get_option('siteurl');
    to return the same value as
    $wp_address = get_bloginfo('wpurl');

    Thread Starter huggie


    OK, thanks for the heads up. In that case I’ll probably use get_bloginfo() for core WordPress information and get_option() for plugin related info.

    Actually you should probably use get_option for everything but the valid arguments that get_bloginfo offers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_bloginfo or get_option’ is closed to new replies.