Boost Your WordPress Site’s SEO with a Dynamic Current Year Shortcode for Copyright Dates

Explore our WordPress category, where you’ll find loads of helpful articles and tutorials for everyone, whether you’re just starting out or a pro developer. Learn about different WordPress themes and plugins that can be applied in various projects according to their specific requirements.

In WordPress, if you want to display the current year dynamically, you can use the following shortcode in your posts, pages, or widgets:
[year]
To implement this shortcode, you can add the following code to your theme’s functions.php file or use a custom plugin:
function current_year_shortcode() {
$year = date(‘Y’);
return $year;
}
add_shortcode(‘year’, ‘current_year_shortcode’);
This code defines a shortcode [year] that will display the current year when used in a post or page. After adding this code, you can use the [year] shortcode wherever you want to display the current year on your WordPress site.