Automatically update copyright year in WordPress to save time and keep your website looking professional. Many site owners forget to update the copyright year manually, which makes their site look outdated. With just a few lines of code or a simple shortcode, you can make your copyright notice always show the current year automatically.
Table of Contents
ToggleWhy You Should Automatically Update Copyright Year
- Professional Look: An outdated year (e.g., 2021) makes your site look neglected.
- Time-Saving: No need to edit the footer every January.
- Dynamic & Accurate: The copyright year always reflects the present date.
Method 1: Simple JavaScript
Add this code snippet in your footer area or HTML block where you want the year to appear:Copyright © <script>document.write(new Date().getFullYear())</script>. All Rights Reserved
If you want to display a date range, use this version:
Copyright © 2020-<script>document.write(new Date().getFullYear())</script>. All Rights Reserved
Method 2: WordPress Shortcode (functions.php)
If you prefer a WordPress-specific solution, you can create a shortcode. Add the following function inside your functions.php file:Now, whenever you want to display the current year, simply use:function year_shortcode() {$year = date('Y');return $year;}add_shortcode('year', 'year_shortcode');
[year]
This works perfectly in posts, pages, and even your footer widget.
Which Method Should You Use?
- Use JavaScript if you just need a quick fix without editing theme files.
- Use the WordPress Shortcode if you want a clean and reusable method across your site.
