1. Home
  2. Knowledge Base
  3. Set the Current Year in Post Title Using The [year] Shortcode

Set the Current Year in Post Title Using The [year] Shortcode

According to a study, humans’ eyes don’t tend to read all the letters one by one, especially on the internet. Instead, it looks out for highlighted words, numbers, and bullet points.

Out of these three, numbers make the most impact on the human brain. Digits or figures stand out among other text which is what has inspired studies that have proven that numbers are a trigger to get your visitors to pay attention to your content. Article titles with digits or years get more clicks than titles without digits. Rank Math makes it very simple to automatically add the current year in your post with the help of a shortcode.

In this knowledgebase article, we’re going to walk you through how to set the current year in the post title using [year] shortcode.

How to Set the Current Year in Post Title Using [year] Shortcode

To set the current year in post title using [year] shortcode, add the following code snippet in your functions.php file:

function filter_the_title( $title, $id ) {
if is_single(){
// make filter magic happen here…
$year = get_post_time( 'Y' );
return ".$title.' '.$year.";
}
return ".$title.' '.$year.";
};

add_filter( 'the_title', 'filter_the_title', 10, 2 );

If you still have any questions about setting the current year in post title using [year] shortcode – you’re always more than welcome to contact our dedicated support team. They are available 24/7, 365 days a year…

Still not using Rank Math?

Setup takes less than 5 minutes including the import from old SEO Plugin!

Buy PRO Version

Was this article helpful?

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket