Skip to main content
Login Join
Snippet · PHP

Add Current Year Shortcode

Shared by Yusuf mudagal · May 3, 2026 · @add_shortcode

48 views
Back to Snippets

Outputs the current site-local year for copyright lines, reusable blocks, and footer templates.

add_shortcode( 'current_year', 'wpfolks_current_year_shortcode' );

function wpfolks_current_year_shortcode() {
    return esc_html( wp_date( 'Y' ) );
}
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments