How To Add Current Date To Divi Footer

I often want to add the current date to the footer in Divi for the copyright statement. I don't want to have to go back through hundreds of websites every year to update the year.

The problem is that the Divi footer doesn't allow for shortcodes and there is no filter you can hook into to process the text before it's output.

Website footer showing custom copyright

Many tutorials say to replace the footer.php file, but that's unnecessary and complete overkill for something so simple.

Thankfully, Divi checks for the existence of et_get_footer_credits() before processing, meaning the developers intended us to overwrite it in our child theme if we needed.

How to add the current date to the Divi footer

To add the current date, or any custom HTML to the Divi footer, we create a function in the functions.php file of our child theme called et_get_footer_credits().

Then we just return whatever we want the footer bottom bar text to be.

In this example, I'm going to replicate the essential Divi code, which keeps it simple and uses their existing security checks.

The code to add the current date is:

function et_get_footer_credits() {
  $credits_format = '<%2$s id="footer-info">%1$s</%2$s>';
  $footer_credits = "© Local Biz Wiz 2019 - " . date("Y");
  return et_get_safe_localization( sprintf( $credits_format, $footer_credits, 'div' ) );
}

This will output "© Local Biz Wiz 2019 - 2022. All Rights Reserved."

Make sure you change the $footer_credits line to the text you want for your website.

The PHP code for outputting the current year is date("Y").

Have a look through the PHP date formatting documentation if you need a variation other than the four digit year.

If you want to do your own safety checks, or you just want the simplest version, you can just output the desired HTML in the return statement without the other lines.

In the Theme Customizer -> Footer -> Bottom Bar, you can leave edit footer credits blank, or just a note to remind you that you've overwritten it in functions.php. It doesn't matter, only people with theme edit capabilities will see the note.

Website footer inside the theme customizer with an arrow pointing to a blank edit footer credits field

And that's the easy way to add the current year to the footer in WordPress Divi theme.

Mike Haydon

Thanks for checking out my WordPress and coding tutorials. If you've found these tutorials useful, why not consider supporting my work?

Buy me a coffee

Leave a Comment