Add a dynamic footer to any WordPress site

Posted by George Nicolaou

On 20 Jul, 2017
George Nicolaou - Senior Web Developer

Assuming you have a child theme so that you don't need to keep editing footer.php every time your parent theme updates. Add the code below to functions.php of your child theme

function whatever_copyright() {
global $wpdb; //get db variable wordpress
$start_year=2000; //set start year here
$company ="Some Company Name."; //set the Company Name for the website footer
$rights ="All rights Reserved."; //the classic All rights reserved tagline
//just some credits to the developer and a nice backlink to his/her website
$developer ='Designed and Developed by <a href="" target="_blank" rel="noopener noreferrer" title="George Nicolaou">George Nicolaou</a>';
//query the db for the first or last date something was published and tell me the year
$copyright_dates = $wpdb->get_results("
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
post_status = 'publish'
$output = '';
if($copyright_dates) {
$copyright = $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
$output = "&copy; " .$start_year.'-'.$copyright . ' '.$company. ' '.$rights. ' '.$developer;
return $output;

Than just call the function inside footer.php. In divi 3.0 I commented out line #39 and added the code below right after that

echo whatever_copyright();

I used this cool plugin that seems to work well with Divi 3.0 called Child Theme Configurator to create the initial child theme


Submit a Comment

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

Pin It on Pinterest

Share This
Divi Theme Code SnippetsAdd a dynamic footer to any WordPress site