The Divi Bottom Bar, located just below the WordPress footer, is a perfect place for Copyright © 2024 information. But a forgotten old year will give your website an outdated, dusty aura. So why not create an automatic feature that keeps the year fresh for you – year after year? Just follow the step-by-step guide below and stop worrying about outdated WordPress footers.
Watch the video or just follow the instructions below if you prefer to read. All the code snippets you’ll need is available for copy & paste in the article. You’ll need the Divi Theme from Elegant Themes but no extra plugins.
👉 Related content: Display current date or year in the WordPress default footer
Updated 2021: Display Current Year Wihtout Custom Code with Divi Dynamic Content (recommended)
This video is a part of our complete Divi & WordPress course. This way, you can create the footer and the bottom bar using the Divi Theme Builder instead. This is easier and much more flexible. And you don’t need to create a child theme or edit any code at all. This is the recommended way of adding the current year in Divi.
The old way: Add current date with custom code
Use this solution only if you have a child theme and if you use the Divi Theme Customizer footer and not the Divi Theme Builder footer.
Step 1. Update functions.php
If you don’t have a child theme, now is the time to get one . Otherwise, your changes will be overwritten next time your theme is updated.
Start in your WordPress dashboard and go to Appearance > Editor. Then select functions.php in your child theme and paste the following code in the end. Save.
// Display current year function year_shortcode() { $year = date_i18n('Y'); return $year; } add_shortcode ( 'year', 'year_shortcode');
👉 Pro tip: The shortcode [year] that we just created can also be used in the body text on all WordPress pages and posts. But if you use Divi, there is a better way: Dynamic content. Read more in the end of this post.
Add current month, day and more date formats.
Just add one or more of the following snippets to functions.php and replace “year” in the footer.php code snippet (step 2).
Code in functions.php | Short Code | Result |
//Display current year function year_shortcode () { $year = date_i18n (‘Y’); return $year; } add_shortcode (‘year’, ‘year_shortcode’); | [year] | 2024 |
//Display current month function monthyear_shortcode () { $monthyear = date_i18n (‘F Y’); return $monthyear; } add_shortcode (‘monthyear’, ‘monthyear_shortcode’); | [month] | April |
//Display current date as YYYY-MM-DD function yyyymmdd_shortcode () { $yyyymmdd = date_i18n (‘y-m-d’); return $ yyyymmdd; } add_shortcode (‘yyyymmdd’, ‘yyyymmdd_shortcode’); | [yyyymmdd] | 2024-04-20 |
//Display current month and year function monthyear_shortcode () { $ monthyear = date_i18n (‘F Y’); return $ monthyear; } add_shortcode (‘monthyear’, ‘monthyear_shortcode’); | [monthyear] | April 2024 |
//Display current day function day_shortcode () { $ day = date_i18n (‘F Y’); return $ day; } add_shortcode (‘day’, ‘day_shortcode’); | [day] | Saturday |
Bonus! Do you want even more date formats to choose from? Here’s the complete date formats list.
Step 2. Copy footer.php to your child theme folder
Now we’ve created the shortcode [year] that will display 2024 if you put it in the body copy of a WordPress page or post. But in order for it to display in the Divi Bottom Bar (and that’s our aim, right?), we need to do a tweak in footer.php (where the bottom bar code is located).
- Use a ftp client (eg FileZilla) or your web hosting file manager to copy the file footer.php from /wp-content/theme/Divi/ to /wp-content/themes/your-child-theme/ (“your-child-theme” should of course be replaced by the name of your child theme).
- Open your brand new child theme footer.php in a editor and search for this code snippet:
<div class="container clearfix"> <?php if ( false !== et_get_option( 'show_footer_social_icons', true ) ) { get_template_part( 'includes/social_icons', 'footer' ); } echo et_get_footer_credits(); </div> <!-- .container -->
3. Replace the code above with the code below;
<div class="container clearfix"> <?php if ( false !== et_get_option( 'show_footer_social_icons', true ) ) { get_template_part( 'includes/social_icons', 'footer' ); } ?> <p id="footer-info">Copyright © <?php echo do_shortcode('[year]');?> DiviMundo. All rights reserved.</p> </div> <!-- .container -->
Change “DiviMundo. All rights reserved.” to the company name and content you want to display. This is now where you edit all the the bottom bar text (but the social media icons are not affected). Save and have a look. It should look something like this:
Explanation to the code snippet:
- Copyright is plain text, displayed as: Copyright
- © is code language for the special copyright character: ©
- [year] is the shortcode that displays the current year automatically.
If you want to modify the background color, font color or font size in the bottom bar it business as usual: Open your WordPress dashboard and go to Divi > Theme Customizer > Footer > Bottom Bar. That was all for today. Enjoy!
Works perfect for me!
Thank you for this! Everything works perfectly, except I’ve added a hyperlink to the php that links to the website designer. The problem is, I don’t know how to add a space between “designed by” and the company name. Can you help?
Please post the code you’ve used and I’ll have a look.
Copyright © All rights reserved. | Site designed by
<?php
Echo "BrainStormes Creative”
?>
WordPress chops your code so I can only see fragments. But you could try to add to create a space.
Of course, WordPress generated a real space. 🙂 You can find the code here: https://kb.iu.edu/d/agjn
Thank you, Victor!
Divi allow now to display date with dynamic content 👉
Yes, It’s a really nice feature. I’ll do a new tutorial on How to apply it soon.
I did accordingly to the tutorial. code insert without issue. but when i go to appearance/customise/footer the menu for footer is missing. can someone please help
Hi Rayden! Not all themes have footer settings in the Theme Customizer. Are you using the Divi theme? If so, have you created a global footer with the Theme Builder? That could remove the footer settings in the Theme Customizer since you will not need them. If you are using the Divi Theme Builder, you can actually use Dynamic Content to add current year without any custom coding at all. Check the link in the end of the blog post.