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

I’m trying to create a set of legal pages, that I can add to any WordPress site.

Within these pages, I want to mention the site name. Is there a built in shortcode or something, that I can include in the pages to allow for this?

For example, I would create a Privacy Page with a variable/shortcode that will display the site name, no matter what site I create the page on.

Cut and paste the language, which would include this variable/shortcode. I want to stay away from editing the functions.php if possible.

Solutions Collecting From Web of "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.

I don´t think that is possible without altering the functions.php or some kind of plugin.

You have to pass the “barrier” between PHP in the background and HTML, CSS etc. in the foreground and that is either done by the functions.php or a plugin.

Altough is not clear whether you have the willing or not to dig inside the code,
a plugin will allow you to use PHP inside a post/page right from the admin panel.

This one seems to be ok for you :
https://wordpress.org/plugins/php-code-for-posts/
Note: I am not involved in this plugin development.

Thanks to it, you might be able to use any WordPress core functions or PHP capabilities inside your posts/pages.

Then for displaying your blog name, use bloginfo( ‘name’ ).

For functions and infos, WordPress codex is helpful.

Not a shortcode, but

<?php echo get_option( 'blogname' ); ?>

does the trick niciely