I just started using Elementor recently (yes, I’m a very late user of the pro version even if I’ve used the free version from time to time), so I could learn it better. I came from using Beaver Builder and am still a diehard BB fan. I like Elementor and want to know how to use it really well, but I think overall BB is still superior in many ways.
But, this is a comparison between Elementor and Beaver Builder. This is all about my path to discovering how to use a dynamic year in Elementor without using all the janky methods I found online using a text box with the dynamic year and then tacking on the text before and after the year.
That solution SUCKS.
I’m used to just plopping a shortcode in a text box with the rest of the content right there in it and the WYSIWYG editor to add links and such. That’s the way it should be. Of course that only works if you have Beaver Themer which can be a bit too expensive for the average user.
Back to Elementor. There had to be an easier way.
And there is!
I thought, why not just create my own damn shortcode that I can use in Elementor anywhere I please, even in a text box.
So that’s exactly what I did. After a few issues with cache and the shortcode not working, I got it working!
So now I can use the following shortcode anywhere in Elementor to output the current year:
[current_year]
Don’t even try to use that shortcode. It won’t work until you’ve followed the instructions in this post on creating a shortcode that outputs dynamically the current year. Then you can use that anywhere in Elementor.
What You Need For This Tutorial
There are a few things you should be comfortable with and have already done before you go through this tutorial. If you haven’t or are uncomfortable, then you should search for tutorials on these. I may write them in the future but for now, Google it.
- A child theme ready to go as your active theme.
- The ability to modify the functions.php file in your child theme.
- Overall comfort with at least minor PHP code manipulation.
- The ability to clear your server’s cache (all of them because I had 5 places I had to clear/reset).
As I said, I’m completely new to Elementor but am absolutely not new to page builders for WordPress. You may have a comfortable lead on me with Elementor knowledge but luckily for me, this is about creating the right custom shortcode and then using it in Elementor, not so much Elementor itself.
I just had to come up with a solution for this problem because Elementor can’t handle it and the current solutions are so so janky I cringed.
How To Create Your Own Dynamic Year Shortcode
Here’s how you create your very own shortcode that will output the current year dynamically anywhere in WordPress or Elementor. It’s nice to not have to worry about the current copyright year and just let it roll over on its own. That’s especially true if you manage a lot of WordPress websites.
It doesn’t matter what your theme is, these instructions work with it. Just please be sure you have set up a child theme before you do this. If you have no idea what I’m talking about, go search out child themes and why you need them.
You have to edit your child theme’s functions.php file and your main theme folder also has one. The problem is, as soon as your theme is updated you’ll lose your shortcode and then wonder what happened.
If you have a child theme setup then this is the perfect use case for it. No matter how many times your theme is updated, your child theme functions.php file won’t be overwritten, and you’ll never lose your shortcode.
Here are the steps you need to create this custom dynamic year shortcode.
Create A WordPress Shortcode
However you want to edit your child theme files, I’ll leave that up to you. My preference is using FileZilla to SFTP into my server and navigate to the following folder:
wp-content > themes > child-theme-folder
You can see I have several theme folders and also several child theme folders. My current active theme is the Hello Elementor child theme. It doesn’t matter if you have the GeneratePress child, Astra child, or Beaver Theme child. They all work the same, and they all will have a functions.php file in them.
Caution! DO NOT use your main theme folder. There is a functions.php file in there, but you should never edit it. When the theme is updated (and it will be) then you will lose your shortcode and anything you’ve done in the functions.php file.
To edit the functions.php file, I use Visual Studio Code which works on all the main operating systems. There are other ways, though.
You can also navigate into your WordPress file structure using CPanel, or even use the theme file editor right on WordPress if you don’t have a security file disabling it. That’s located in Appearance > Theme File Editor.
Here’s how you do it on WordPress if you have access to the theme file editor, which might be a good idea to turn off. That’s for another tutorial.
Step 1: Hover over Appearance
Step 2: Click Theme File Editor.
Step 3: Select your child theme from the drop-down.
Step 4: Click the Select button.
Step 5: Select the functions.php file.
Step 6: Paste the custom code I provide you below at the end of the file (leave some space above it).
Step 7: Click the Update File button.
That’s it! You now have a new shortcode available in Elementor or anywhere on WordPress really.
Here’s how that same functions.php file looks like in Visual Studio Code that I then replace on the server using FileZilla.
No matter if you use SFTP, Theme File Editor, or CPanel, they all have the same end result, and you need the same code:
// Create current year shortcode
function current_year_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('current_year', 'current_year_shortcode');
Now you’ve created a shortcode that you can use anywhere on WordPress, Elementor, or any other page builder that doesn’t have a dynamic year shortcode already built in.
This is the shortcode you created:
[current_year]
Congratulations! You now have a dynamic shortcode you can use anywhere in Elementor, including in the footer for your copyright notice.
Mine didn’t work right away and here was my issue: I have about 50-million levels of cache on my server to make it crazy fast. So, I had to clear my OPcache and Object-Cache, clear the CDN cache, clear the WP Rocket cache, preload the cache, and also clear the used CSS in WP Rocket as well.
After doing all of that then my shortcode worked!
Check out out:
2024Placing The Copyright Year In Elementor
Here’s where the magic comes in.
If you did any searching for inserting a dynamic copyright year in your Elementor footer then you’re definitely ran across this solution. That’s all I could find, and it’s such a bad solution!
What happens when I want to make my site title linked or perhaps add even more? I end up with a tiny little field packed with HTML and incredibly difficult to edit.
So, now you get to end up with this because you have the magic shortcode. It won’t always show up in the page view right away but be patient. Save your footer and then load the preview. You’ll see the current year inside your text, and it will update every year, automatically!
I just inserted a text editor element to my footer in the Elementor Theme Builder and used the special character button to insert the copyright icon, typed in Copyright, pasted the shortcode in there, then placed my site title and linked to the home page. I even added a bit more text and the privacy policy linked in there too.
Isn’t that beautiful?
Just don’t use the shortcode element, and you’ll be good with formatting any text you want around the copyright year. You can easily change the font size, change link colors, etc. and it will always look good.
You don’t want to use the shortcode element because then you lose the entire style tab which lets you make your copyright text look good. There’s really no reason to ever use the shortcode element because in almost all cases the text editor with a shortcode in it does the same thing.
That looks a lot nicer than anything I could have done with the other solution for a dynamic copyright year in Elementor. The current year shortcode for placing the copyright year into an Elementor text field is much better.
Wrap Up
Now that’s how I WordPress! There’s always a better solution to do things. You don’t just have to accept that Elementor has no year shortcode built in, and you can, in fact, create your own.
That’s what we did, and it’s much more versatile because we can add as much text, links, or anything easily in the editor rather than a tiny little text field. I like the flexibility and ease of use which this solution has afforded me.
Now, the only improvement we could make is to also make the site name dynamic in case I change the name of the site. I did that in Beaver Builder but honestly, it’s not a dealbreaker because it’s not something I’d do yearly if ever.
There are lots of other things you can create a shortcode for on WordPress, not just the year for the copyright year. Those are for another time, though, and honestly I think you’ll have to come up with the use cases for those.
Happy copyright year shortcoding!