Skip to content

How to add year which changes dynamically in Woocommerce or WordPress

You simply need to edit your functions.php. function yearshortcode() {<br> $year = date('Y');<br> return $year;<br> }<br> addshortcode('year', 'yearshortcode'); Now go to your Footer widget and add the shortcode or…

Sohaib Khan1 min read
How to add year which changes dynamically in Woocommerce or WordPress — editorial illustration

You simply need to edit your functions.php.

JavaScript5 lines
function year_shortcode() {<br>
  $year = date('Y');<br>
  return $year;<br>
}<br>
add_shortcode('year', 'year_shortcode');

Now go to your Footer widget and add the shortcode or where ever you wanted to add the YEAR for example 2020 by using

Special Thanks to CSS-Tricks

Was this worth your time?

Continue reading

Full archive