auto-updating copyright shortcode on wordpress

WordPress Shortcode for Auto-Updating Year Script For Copyrights

For the last few years, I’ve been using a small script inline on all of my projects for an auto-updating year within the copyright section of my websites, normally in the footer.

It would look something like this:

&copy;2012-<script>document.write((new Date).getFullYear());</script> Siam Tek is a Trademark of Siam Tek Web Design Group

And while this works well most of the time, other times it can cause conflicts with Themes, and page builders (which are often built on javascript frameworks like EmberJS or BackboneJS).

Since I have battled with this for a while, the need for a different (non-javascript) solution is very important to continue with an auto-updating year the copyright text at the bottom of my sites.

Enter (drumroll, please) the shortcode, which can be added in the child theme’s functions.php file (SOURCE: My Github Gist):

Once the functions.php is saved, you can use the shortcode [[year]] in all shortcode enabled areas of your website to get the same result!