How to display the site name in a WordPress page, or post

No, there is no core shortcode for this.

The site name is available as an option, in facts get_option('blogname') returns the blog name.

Moreover, get_bloginfo('name') / bloginfo('name') can be used to get / echo the site name.

Of course, you can’t use that functions as a shortcode by default, so if you want to obtain that, and you don’t want to edit theme functions.php you need a plugin or MU plugin.

The latter is probably preferable in network install.

The plugin

Below there is a working plugin (that can be used as MU plugin too) that does the trick:

<?php
/**
 * Plugin Name: Bloginfo Shortcode
 * Description: Allows bloginfo() as a shortcode.
 * Author: Giuseppe Mazzapica
 * Author URI: http://gm.zoomlab.it
 * License: MIT
 */

add_shortcode('bloginfo', function($atts) {

   $atts = shortcode_atts(array('filter'=>'', 'info'=>''), $atts, 'bloginfo');

   $infos = array(
     'name', 'description',
     'wpurl', 'url', 'pingback_url',
     'admin_email', 'charset', 'version', 'html_type', 'language',
     'atom_url', 'rdf_url','rss_url', 'rss2_url',
     'comments_atom_url', 'comments_rss2_url',
   );

   $filter = in_array(strtolower($atts['filter']), array('raw', 'display'), true)
     ? strtolower($atts['filter'])
     : 'display';

   return in_array($atts['info'], $infos, true) ? get_bloginfo($atts['info'], $filter) : '';
});

The plugin above can be used to output (almost) all the informations that get_bloginfo() is capable to return, I just removed the deprecaded and discouraged informations.

Usage

If you have the code above in a MU plugin, or in an active plugin you can output site name in this way:

[bloginfo info='name']

All the informations you can get are listed in the $infos array.

Leave a Comment