Here Are Two Ways To Keep Your Copyright Date Current

copyright year

Keep your copyright year current

One of the most neglected parts of a website is the copyright date. I can’t tell you for certain how many websites I’ve come across with outdated copyright dates, but it is quite a few.

You may have noticed these too. Maybe you visited a website to read their latest article and noticed that their copyright year lists 2008, instead of the current year of 2014.

While this probably isn’t a major cause of concern, keeping everything current on your website lets visitors know that you pay attention to details. Neglecting the little things on your website often leaves visitors with the impression that you may be sloppy and unprofessional.

Some people add the copyright year manually to the footer of their site, and while that seems the easiest route to take, it requires that you be vigilant in updating that text year after year. It’s easy to forget, and before you know it your copyright date is forgotten and years behind the times.

Instead of editing the copyright manually how about automating the process?

There are two different ways I use to ensure that the copyright info is always up to date. One is where you define the initial year and then the current year is automatically populated, and the other is automatically generated based on the dates of the content within the WordPress site. I have used both with great success.

First, let’s look at the first method I suggested. I generally add the copyright code directly into the theme’s footer.php file, such as in the example below:

<p class="copyright">&copy; Copyright <?php bloginfo('name'); ?> 2008 - <?php echo date('Y'); ?> All Rights Reserved</p>

Notice that I entered “2008” as the initial year in the copyright date span and followed it with a short PHP date snippet. This snippet will automatically output the current year, so there is never a need to go back and edit your copyright On New Year’s Day. It just works.

The second method I use is a little more involved, as I create a function in the WordPress theme’s functions.php file, and then call for that function in the footer template file. This method will comb through the dates on all your posts and pages and generate a copyright timeline based on your earliest and latest publishings.

Here is the code to add in the functions.php file:

function footer_copyright() {
   global $wpdb;
   $copyright_dates = $wpdb->get_results("
   SELECT
   YEAR(min(post_date_gmt)) AS firstdate,
   YEAR(max(post_date_gmt)) AS lastdate
   FROM
   $wpdb->posts
   WHERE
   post_status = 'publish'
   ");
   $output = '';
   if($copyright_dates) {
      $copyright = "Copyright &copy; " . $copyright_dates[0]->firstdate;
      if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
         $copyright .= '-' . $copyright_dates[0]->lastdate;
      }
      $output = $copyright;
   }
   return $output;
}

To use this in the WordPress theme, simply navigate to the template file and location you wish to insert this and enter:

<?php echo footer_copyright(); ?>

This will print out “Copyright ©” and then echo the year of your first publication folowed by a hyphen and then the most recent year you published an article. To really fill out a good copyright line, try this instead:

<p class="copyright"><?php echo footer_copyright(); ?> <?php bloginfo('name'); ?></p>

The above line will do everything the footer_copyright function does, but it will also add your website’s name after it. I’ve included this function many, many times when because it’s just one of the many things I like to have automated for my clients.

Does your copyright info stay updated? If you don’t already have an automated system in place for this, try one of the above suggestions and add a little more simplicity to your website maintenance!

One Comment

  1. Jeff Nelson Aug 18, 2014 at 6:32 am

    Works great, thanks for this.