Add an auto-updating Copyright statement to your WP site

Question: It's midnight on the 31st December this year, What are you doing at that exact moment?

If you answered, ‘Updating the year on my copyright footers across all my WordPress websites, of course!” then you're an idiot.

You should be drinking champagne and trying to remember the words to ‘Auld Lang Syne‘.

I've created the world's simplest shortcode that will update your [tooltip tip=”The bit at the bottom of your website that says ‘Copyright 2017 MyCompany'”]copyright statement[/tooltip] automatically, meaning you can set it once and forget it.

Here it is:

// Add this to the bottom of your functions.php file in your child theme. 
// (Not using a child theme? You're a fool! Follow these instructions now, or next time
// you update, your changes could be overwritten:
// https://thrivethemes.com/tkb_item/how-to-set-up-a-thrive-child-theme/

/**
 * Shortcode that generates the 'copyright' statement for the bottom of each page
 * (also inserts the right year!)
 */
add_shortcode('dm_copyright', 'dm_generate_copyright');

/**
 * Returns the right date and a copyright statement
 * $attributes  = NULL
 */
function dm_generate_copyright( $attributes ) {
  // IMPORTANT! Change the words 'Dallas Matthews' below for your company name (or your own name)!
	return "© Copyright " . date("Y") . " Dallas Matthews";
}

Instructions:

  1. Find your functions.php file in your child theme. (Not using child themes? You idiot!)
  2. Paste the above in (from line 7 onwards) at the end of the file. (If there is a ‘?>' tag, paste it above that)
  3. Go to your footer and type ‘[dm_copyright]'

That's it!

Advanced & Troubleshooting

  • If you don't see the changes immediately, check that you don't have a caching plugin that needs to be emptied.
  • I called the shortcode ‘dm_copyright' so it doesn't clash with any other shortcode or function, but feel free to change it to whatever you like.
  • You can add as much or as little to the output as you like. E.g. ‘Copyright 2017 Dallas Matthews Ltd, the best marketing consultancy in the world.'

UPDATE 23/11/17:

It occurred to me that most people would want their ‘copyright' statement to read the same as their site title.

In other words, if they have set the ‘Site Title' (in Dashboard –> Settings –> General) to ‘Joe Bloggs' Blog', then they would probably want the copyright to say ‘Copyright 2017 Joe Bloggs' Blog'.

If this is you, then just use the built-in WordPress function get_bloginfo() like this:

return "© Copyright " . date("Y") . " " . get_bloginfo('name');

(This would replace the second-to-last line in the above example).