Search
Close this search box.

Useful Functions.php Hacks

[updated_on]
Share this post:

Automatically update the Copyright text to the current year

Copy the block of code below in your functions.php file.

function copyright_text($year_one, $website_name) {
  $year = date('Y');
  echo "© Copyright ";
  echo $year_one;
  if($year_one != $year) {
      echo "-$year";
  }      
  echo ", $website_name, All Rights Reserved Worldwide.";
}

Copy this block of code into your footer file where you want to add the copyright to appear. If your theme already generates a copyright then you will want to remove it or comment it out. It is a best practice to make changes to theme files only in a child theme. Here is a walkthrough on YouTube of how to create a child theme in case you need it.

<div class="copyright"><?php copyright_text(2014, "Your Website Name"); ?></div>
Share this post:

Leave a Comment

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

WPLearningLab