Home / Admin / Dynamic Current Year
Duplicate Snippet

Embed Snippet on Your Site

Dynamic Current Year

The shortcode prints out dynamic current year wherever used [current_year] in the frontend layout, e.g. 2020 to 2025 > 2020 to [current_year]. Interestingly, there are many variations.

Code Preview
php
<?php
function current_year_shortcode() {
    $year = date('Y');
    return $year;
}
add_shortcode('current_year', 'current_year_shortcode');   

Comments

Add a Comment