How to add Year Shortcode in wordpress

In this article, we have going to learn about adding Year Shortcode in WordPress

If you are looking for a way to add the current year in WordPress website without using any external plugin.

To add the current year on your website you don’t need any 3rd party plugin to display it in the footer of your website. You will have to add the following code in your function.php file and we will create a shortcode that will display on the front-end to display the current year.

function current_year_shortcode() {
$year = date('Y');
return $year;
add_shortcode('currentyear', 'current_year_shortcode');

The above function will return us the current year. To display the year on the front end you will need to add one shortcode that we have created using the above function.

Using the shortcode

Use [currentyear] in your posts.

This will display the current year on your website using Year Shortcode in WordPress.

Next Post

Leave a Reply