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

I was just wondering if calling get_bloginfo too many times was going to harm performance in a theme and if the data should just be put into its own var?

share|improve this question
get_bloginfo() returns a global variable if I recall. So calling it repeatedly doesn't query the database multiple times. – Cristian Jul 15 '11 at 19:52
up vote 0 down vote accepted

get_bloginfo() is not cached and calling it over and over would harm your performance just like creating many calls to the database yourself.

a simple solution which doesn't evolve any caching in to minimize the database and function calls by defining a an array with all the info you need and save that as an option in the wp_options table.

then in your header.php globalize a variable and assign that option to it and every were in your them you can just use that, something like this:

in your functions.php

function set_get_my_blog_info(){
    $my_blog_info = get_option('my_blog_info');
    if ($my_blog_info === false){
        global $wp_version
        $lang = get_locale();
        $lang = str_replace('_', '-', $lang);
        $my_blog_info = array(
            'url' => home_url(),
            'wpurl' => site_url(),
            'description' => get_option('blogdescription'),
            'rdf_url' => get_feed_link('rdf'),
            'rss_url' => get_feed_link('rss'),
            'rss2_url' => get_feed_link('rss2'),
            'atom_url' => get_feed_link('atom'),
            'comments_atom_url' => get_feed_link('comments_atom'),
            'comments_rss2_url' => get_feed_link('comments_rss2'),
            'pingback_url' => get_option('siteurl') .'/xmlrpc.php',
            'stylesheet_url' => get_stylesheet_uri(),
            'stylesheet_directory' => get_stylesheet_directory_uri(),
            'template_url' => get_template_directory_uri(),
            'admin_email' => get_option('admin_email'),
            'html_type' => get_option('html_type'),
            'version' => $wp_version,
            'language' => $lang     
    return $my_blog_info;

this will save most of the get_bloginfo options into one option in the database and will only run once.

then in your header.php add

global $my_blog_info;
$my_blog_info = set_get_my_blog_info();

and after you do that you can use that array anywhere you want in your theme, for example instead of:

echo get_bloginfo('url');

simply use your array:

echo $my_blog_options['url'];
share|improve this answer
This is a really ugly, unnecessary solution. See answer below ( wordpress.stackexchange.com/a/23110/16672 ) – jondavidjohn May 14 '13 at 18:55

While there is no inherent caching in get_bloginfo(), most of information it retrieves is from options and get_option() is cached.

Holding value you need in a variable for using several time is still (marginally in most cases) faster than function call, but I wouldn't bother with explicit dedicated caching.

share|improve this answer
Indeed; in fact, it appears that the only get_bloginfo() parameters that don't derive from get_option(), get_site_option(), a global variable, or a constant, are the feed link parameters that derive from get_feed_link(), which dynamically builds the feed link. – Chip Bennett Jul 15 '11 at 23:44

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.