X

Display Bloginfo Using Shortcode

Snippets by IsItWP

Are you looking for a way to call bloginfo parameters using shortcode? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display bloginfo using shortcode in WordPress.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function bloginfoSC( $atts ) {
             extract(shortcode_atts(array(       'value' => '',   ), $atts));
             return get_bloginfo($value);
}

add_shortcode('bloginfo', 'bloginfoSC');
[bloginfo value='name']
[bloginfo value='url']
[bloginfo value='description']
[bloginfo value='charset']

Here’s a list of all the bloginfo parameters.

name                 = Blog name
description          = Blog description
admin_email          = admin@email.com
url                  = http://example/home
wpurl                = http://example/home/wp
stylesheet_directory = http://example/home/wp/wp-content/themes/child-theme
stylesheet_url       = http://example/home/wp/wp-content/themes/child-theme/style.css
template_directory   = http://example/home/wp/wp-content/themes/parent-theme
template_url         = http://example/home/wp/wp-content/themes/parent-theme
atom_url             = http://example/home/feed/atom
rss2_url             = http://example/home/feed
rss_url              = http://example/home/feed/rss
pingback_url         = http://example/home/wp/xmlrpc.php
rdf_url              = http://example/home/feed/rdf
comments_atom_url    = http://example/home/comments/feed/atom
comments_rss2_url    = http://example/home/comments/feed
charset              = UTF-8
html_type            = text/html
language             = en-US
text_direction       = ltr
version              = 3.1

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 50+ best WooCommerce themes for your online store and 7 best WordPress GDPR plugins to create a GDPR compliant site.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[60% OFF Today!]
[60% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]