How to automatically update WordPress footer copyright year using a custom shortcode?
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:em***@em***.com" data-original-string="YM91EYXl/Yiu1LHoaW/4Pw==4fbmfhfRKZ0mQMljs3M7WBO9g==" title="This contact has been encoded by Anti-Spam by CleanTalk. Click to decode. To finish the decoding make sure that JavaScript is enabled in your browser.'>
em***@em***.com
</a>"; return $Email;} add_shortcode('EmailShortcode', 'EmailFunction');
Pretty useful 🙌🏼
Pretty useful