This article is all about WordPress Current Year Shortcode – a guide to display the current year in your WordPress website content using a simple shortcode.

In this article, I will article, we are exploring 2 easy methods to show 2024, which updates dynamically when the year changes via:

  • Using a WordPress shortcode plugin – AIO Shortcodes
  • Without plugin (old method via functions.php file)

The first method is our favourite way to get current year using a WordPress shortcode that also best fits the option for non-codes.

Now let’s get started.

2 Easy Ways To Display Current Year in WordPress Using A Shortcode

To get started with the tutorial, I would like to tell you how I display 2024 or current year number using a shortcode on my website. This is also the first method we recommend strongly.

Method 1: Install AIO Shortcodes

aio shortcodes

We built AIO Shortcodes (the best WordPress shortcode plugin in 2024) for adding dynamic content to easier for bloggers, especially non-coders.

I don’t want to get into details here about the plugin AIO Shortcodes and it gives you instant access to 100+ dynamic shortcodes that let you automate your content and keep it up to date.

Once you have installed AIO Shortcodes plugin, just place the shortcode, just place the shortcode [aio_year] and save your post/page. It will get current year data and update automatically.

This is what you write in the post editor:

wordpress current year shortcode

And this is what display to your website readers:

current year shortcode wordpress

The best part is that you have to place the year shortcode once only, and will keep your current year number up to date forever.

Here are the best possible year shortcodes offered by AIO Shortcodes:

  • [aio_year]: Output current year like 2024
  • [aio_year go="3"]: Output 3 years after the current year like 2027
  • [aio_year go="-2"]: Output 2 years past the current year like 2022

There are many more additional options available for AIO’s current year shortcode that you can read on our docs year page.

Method 2: Get Current Year In WordPress Without Plugin

If you prefer to avoid adding another plugin to your WordPress site, there’s a straightforward method to automatically display the current year using a shortcode.

Let’s dive into it.

Note: This method requires custom code addition to your theme’s functions.php file. Thus, it’s advisable to use a child theme when editing the functions.php file to avoid losing modifications during theme updates.

The first step is: Navigate to your WordPress dashboard, head to Appearance » Theme File Editor, and then select the functions.php file from the list on the right.

wordpress theme editor

Next, add the following code at the bottom of your functions.php file.

function current_year_shortcode() {

$year = date('Y');

return $year;

}

add_shortcode('year', 'current_year_shortcode');

This simple code snippet creates a shortcode [year] that will output the current year.

Note: In the code above, the yellow text is the name of the shortcode. You can rename it at your convenience.

functions.php file

Finally, click the Update File button at the bottom to save the code.

Now your current year shortcode – named [year] is ready to use within your WordPress posts and pages.

To use the shortcode, go to any post or page and inside the content editor place [year] and save it. It will automatically get and display the current year number that remains automatically updated.

By following these steps, you’ve successfully added a dynamic way to display the current year without relying on an additional plugin.

FAQs – Frequently Asked Questions

Have questions about the current year shortcode in WordPress? Check out these common queries:

What is a shortcode?

In WordPress, a shortcode is a simplified code enclosed in square brackets like [shortcode], used to execute predefined functions or display dynamic content with minimal effort.

How to get the current year in WordPress with a plugin?

Simply install a WordPress shortcode plugin like AIO Shortcodes, and use the provided shortcode, such as [aio_year], to effortlessly display the current year in your content.

How to display the current year in WordPress without installing a plugin?

Without installing a plugin, you can add a PHP shortcode directly to your theme’s functions.php file. For instance, [year] can be used to display the current year.

Can I display past and future years with WordPress shortcodes?

Absolutely! AIO Shortcodes offers versatility, allowing you to display not only the current year but also past and future years. For example, [aio_year go="5"] shows the year five years ahead.

Is AIO Shortcodes suitable for non-coders?

Yes, AIO Shortcodes is designed to be user-friendly, making it a perfect fit for bloggers and individuals without coding expertise.

How often do AIO Shortcodes update the displayed year?

AIO Shortcodes update the displayed year automatically, ensuring your content remains current without any manual intervention.

Final Thoughts On WordPress Current Year Shortcode Tutorial

We hope via this article you found a straightforward and effective way, how to easily display the current year on WordPress website with a shortcode.

For those aiming for simplicity and customizable attributes, AIO Shortcodes stand out. With features like displaying current, past and future years, this plugin streamlines the process, making it accessible to all users.

Install AIO Shortcodes today for a hassle-free experience, ensuring your content stays fresh effortlessly. Cheers to a more dynamic and engaging WordPress website!

Still not using AIO Shortcodes?

Install our plugin to boost your site’s content SEO, automate your affiliate marketing, and lots more, just by using these simple WordPress shortcodes.

FTC Disclosure: AIO Shortcodes content is reader-supported. This means if you click on some of our links and make a purchase, we may earn a commission at no extra cost to you – Read Affiliate Disclosure