How to Add a Site Name Shortcode to WordPress

A cosmic cloud of gases condenses under its own gravity, forming a star. Generations upon generations of single-celled organisms lead to multi-cellular complex life. And your humble blog has grown beyond its seminal inspiration.

Change happens, and you don’t have to find yourself in a situation where if you decide to change the name of your site, you’ll need to find and replace potentially hundreds of mentions of the old name to keep your branding consistent.

Most of my online projects suffer from many identity crises as I refine over and over again what it is I want to do with my online presence. To save myself all of the trouble of laboriously updating references to my site’s title throughout all of a its content, I started using an incredibly simple WordPress shortcode to do the work for me.


There are multiple ways in which you can add this shortcode to your WordPress installation, among them:

  • Add the following code block to your theme’s functions.php file.
  • If you’re using Thesis 1.8.5, add the following code block to your theme’s custom_functions.php file.
  • If you’re using a custom plugin to hold your site’s customizations, add the code block to it.
  • Last, you can ignore the code block altogether by downloading this code block as a WordPress plugin, which can then be uploaded via your site admin panel’s Plugins → Add New page.

The Code

 * [sitename] — Site name shortcode
 * @via
add_shortcode( 'sitename', function() { return get_bloginfo(); } );


Once installed, you can insert your site name into your content by using [sitename] anywhere where shortcodes are processed, such as in any of your posts or pages.

Now, no matter how many times you update your site’s title in Settings -> General, you can be assured that your content will always refer to its current name!

If this shortcode was useful to you, you might also appreciate one of my other WordPress tweaks, and of course, don’t forget to like this page and share it with your fellow WordPress’ers!

3 thoughts on “How to Add a Site Name Shortcode to WordPress”

    1. Hey, Ace! If I understand it correctly, you’re wanting to have a shortcode that you can use to display a post or page’s title in the content?

      If that’s right, try this instead of the code above:

       * [title] — Content title shortcode
       * @via
      add_shortcode( 'title', function() { return get_the_title(); } );

Leave a Comment

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

Use your Gravatar-enabled email address while commenting to automatically enhance your comment with some of Gravatar's open profile data.

Comments must be made in accordance with the comment policy. This site uses Akismet to reduce spam; learn how your comment data is processed.

You may use Markdown to format your comments; additionally, these HTML tags and attributes may be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.

the Rick Beckman archive
Scroll to Top