Shortcode: Use bloginfo in post content

Add following snippet to “functions.php”

Usage

[bloginfo key='siteurl']

Snippet

add_shortcode('bloginfo', 'bloginfo_func');
function digwp_bloginfo_shortcode($atts) {
    extract(shortcode_atts(array(
            'key' => '',
            ), $atts));
    return get_bloginfo($key);
}

Result

WordPress’s bloginfo function has detailed information about the blog. Some times you want to put it in post or page contents.  This is a quick way to do it. See full details of the functions in Codex.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>