How to automatically update WordPress footer copyright year using a custom shortcode?

1.66K viewsWordPress

How to automatically update WordPress footer copyright year using a custom shortcode?

WordPress footer copyright section is a unique place for every websites.

The major issue which I see is website owner or developer have to update that copyright year manually year by year. Some websites have not been updated for a long time. So copyright year also is old.

To resolve this issue, here I created simple custom wordpress shortcode function. 

//Current Year - [currentYearShortcode]
function currentYearFunction() { $currentYear = date("Y"); return $currentYear;} add_shortcode('currentYearShortcode', 'currentYearFunction');

You can insert this code to function.php file via FTP or by visiting WordPress Dashboard –> Apperance –> Theme Editor –> Function.php

Then you can replace [currentYearShortcode] shortcode with footer section year.

You done!!

P:S: And also, In static websites there are same Email, same Contact number, Same Address in several pages. We changing those values we have to changes values by visiting all pages. To this, we can create simple shortcodes just like above to display Phone number, Address, Emails etc. Then we only have to update in one place. Shortcodes updates other places.

//Email - [EmailShortcode]
function EmailFunction() { $Email = "<a href='mailto:[email protected]'>[email protected]</a>"; return $Email;} add_shortcode('EmailShortcode', 'EmailFunction');
Sahana Answered question January 29, 2024

Pretty useful 🙌🏼

4

Thank You for sharing this. I used this code today.

Sahana Answered question January 29, 2024
1