Show Dynamic Current Year in Post Title and Body Automatically

Dynamic current year in post title

You may have seen that the post title is a very important part of your blog posts. When you search for a particular keyword or phrase in Google, the title of the blog post will come up as the first result.

According to research done by some marketers, people do not read everything but only a few highlighted things. Numbers are also highlighted in the text and impact the human brain. As a webmaster, you must know how to add the current year in the post title automatically in the post title.

There are many SEO (Search Engine Optimization) companies out there who charge a lot of money for adding this to your website. However, if you make sure that you add this yourself to your website, you will be able to save a lot of money.

In this article, we will learn how you can Show Current Year in WordPress Post Automatically with different methods. 

Why do You need to Show the Current Year in Post Title?

Let’s learn with an example when you are searching against the keyword ‘best gaming laptops, you see multiple results in the SERP. And Confused which is the latest info suddenly you see a title with the current year. In my opinion, you must have to prefer to visit this one. The current year can make a huge difference in your website traffic.

How to Add Dynamic Current Year In Post Title Automatically

With Plugins

You want to show the year in your post titles, right? We can use the year function in the WordPress plugin to add the current year to your post titles automatically.

I use the current year function in this way. Here’s a simple tutorial to add the current year in the post title automatically using the WordPress year() function. You can also use this method to add the current month or day to your post titles.

If you are using an SEO plugin you can do it using this but the drawback is that you can only add the current dynamic year in the meta title, not in the title.

For Yoast, you have the %%currentyear%% tag in the meta title setting, and in the case of rank math, you have to add the %currentyear% tag in the meta title.

If you need to show dynamic year in the title so just install this plugin.

Without Plugins

If you don’t want to use plugins you can do it by adding the code below to your theme’s functions.php file

The code below adds a simple function to your theme’s functions.php file that allows you to insert the current year into the post title. You can use it on posts, pages, and custom post types.

add_shortcode( 'year', function() { return date('Y'); } ); add_filter( 'the_title', 'apply_shortcodes' ); add_filter( 'the_seo_framework_title_from_custom_field', 'apply_shortcodes' ); add_filter( 'the_seo_framework_title_from_generation', 'apply_shortcodes' );

How and where to add Code?

Go to the WordPress dashboard and click on Appearance > Editor

Add and paste the code to the “functions.php” file. Make sure to add the code at the very end of the file.

Once you add this code in your function.php file then anywhere in the post either it is the title or body you just write [year] where you want to show the current year.

1 thought on “Show Dynamic Current Year in Post Title and Body Automatically”

Leave a Comment

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

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.