A small feature that I always end up adding to most client websites I make, particularly larger template themes that I use for rapidly developing multiple projects is a very simple but useful shortcode for displaying the current year.

Paste this into your functions.php of your child theme.

  1. /* create shortcode for displaying dynamic year in copyright footer */
  2. function year_shortcode() {
  3.    $year = date('Y');
  4.    return $year;
  5. }
  6. add_shortcode('year', 'year_shortcode');

Place the year shortcode into any wordpress text edit / text field and it will print out the current year.

  1. [year]

Ideal for including in footers or copyright content so that it’s always up to date (particularly if you start needing to editing an entire template page for just that one date or you don’t have easy access to those areas in your theme files.

Leave a Reply

Your email address will not be published. Required fields are marked *