It can often drive one crazy when you have to change the current year in the footer of the website every year. WordPress, for no specific reason, doesn’t have an in-built feature that allows you to display the current year.
The best way to tackle this, without installing any plugins, is to have a shortcode that does it for you.
How To Display The Current Year in WP Footer
Add the following shortcode in your functions.php file:
<?php
/* Shortcode: Current Year */
function wps_current_year() {
ob_start();
echo date('Y');
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
add_shortcode('wps-year','wps_current_year');
After adding that code, you will now be able to use [wps-year]
in place of manually writing the year, such as “2020”, in the footer of your WordPress website.