Toolsnip

Wordpress: Dynamic Copyright Year Shortcode

Automatically update the copyright year on your WordPress site with this simple shortcode snippet, ensuring accuracy and ease of maintenance.

Keeping site footers updated with the current year is a common need. This snippet creates a shortcode that dynamically displays the current year, simplifying maintenance and ensuring accuracy.

The add_shortcode function is used to register a new shortcode [current_year], which outputs the current year using PHP's date function.

This approach eliminates the need for manual updates to the footer or other areas of the site where the year is displayed, enhancing site professionalism and compliance with copyright standards.

Integration examples are provided, showing how to use the shortcode in WordPress posts, pages, and widgets, along with customization options to adjust the format of the year if needed.

Additional tips on how to extend the shortcode for other dynamic date-related content are also discussed, offering further utility beyond just the current year.

Snippet Code

Version Compatibility

This snippet is compatible with WordPress 2.5 and later, where shortcodes were introduced.

Required PHP Version

PHP 5.2 or higher

Wordpress Core Functions Used

Use Cases

  • content display
  • footer customization
  • site updates