Sitename Shortcode

If your WordPress-powered blog has suffered the same problem as mine — identity crises and changes through the years, resulting in blog posts throughout the archives referring to the site by names which are no longer accurate or which may no longer make any sense whatsoever — there is a very easy solution: the sitename shortcode.

Simply insert the following code into your WordPress theme’s functions.php file (or your custom_functions.php file if you’re using Thesis 1.8.5), which will allow you to always reference your site by its current correct name in your posts, even if years later the site name changes:

/**
* Site name shortcode
*/
function custom_sitename_shortcode() {
	return get_bloginfo();
}
add_shortcode( 'sitename', 'custom_sitename_shortcode' );

Once done, you’ll be able to use the [sitename] shortcode to reference the name of your site, without worry as to what happens when your site’s identity evolves.

Join the Discussion

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

Comments must be made in accordance with the comment policy.

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=""> <s> <strike> <strong>