Home / functions.php / Display bloginfo using shortcode
  • How to Display bloginfo using shortcode

    bloginfo-shortcode

    Adding this snippet to the functions.php of your wordpress theme will let you call bloginfo parameters using shortcode. Bellow is also a list of parameters that can be use with the shortcode. This little snippet has come in handy with a few projects I have worked on.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    function bloginfoSC( $atts ) {
                 extract(shortcode_atts(array(       'value' => '',   ), $atts));
                 return get_bloginfo($value);
    }
    add_shortcode('bloginfo', 'bloginfoSC');
    
    ( click code to copy )

    wordpress snippet : SHORTCODE

    <>
    [bloginfo value='name']
    [bloginfo value='url']
    [bloginfo value='description']
    [bloginfo value='charset']
    
    ( click code to copy )

    wordpress snippet : 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