Bloginfo Function Shortcode

Bloginfo Function Shortcode

The bloginfo() function in WordPress gives you access to lots of useful information about your site. Here is the complete list. This can be used inside Page/Post content itself using shortcode, here we can make a shortcode to return the values. Add this functin to your functions.php file in your theme:

[php]

function qt_bloginfo_shortcode( $atts ) {
extract(shortcode_atts(array(
‘key’ => ”,
), $atts));
return get_bloginfo($key);
}
add_shortcode(‘bloginfo’, ‘qt_bloginfo_shortcode’);

[/php]

Now you can output any of the values by calling that shortcode with attribute “key”. For example, the name of your site:

[html]
[bloginfo key=’name’]

<img src="[bloginfo key=’template_url’]/images/logo.jpg" alt="[bloginfo key=’name’] logo" />
[/html]

I'm a web developer / PHP programmer. I am also working on custom plugin development of wordpress.