Thursday, July 20, 2023

How to show the current year in WordPress posts

Add this function in the functions.php file.

function current_year() {
    $year = date('Y');
    return $year;
}

add_shortcode('year', 'current_year');

No comments:

Post a Comment

7 Must-Have WordPress Plugins to Boost Your Website in 2026

Want to make your WordPress site faster, smarter, and more powerful? Plugins are the secret weapon that can transform a basic blog into a pr...