elin-r
2/20/2017 - 6:52 AM

Create shortcode for current year / Add to child theme functions.php

Create shortcode for current year / Add to child theme functions.php

<?php

/**
 * Copyright Shortcode
 * Use it like this:  -->  [c] [y] Site Name - or [cy] Sitename - or any other combination you want.
 */

add_shortcode( 'y', 'jr_cy_y' );

function jr_cy_y() {
  $date = getdate();
  return $date['year'];
}

add_shortcode( 'c', 'jr_cy_c' );

function jr_cy_c() {
  return '&copy;';
}

add_shortcode( 'cy', 'jr_cy_cy' );

function jr_cy_cy() {
  return jr_cy_c() . ' ' . jr_cy_y();
}