Creating a Year shortcode
-
I am trying to create a shortcode called ‘year’ that I can place within pages as I have documents which should always refer to the current year. I have used the following in my functions.php:
function year_shortcode() { $year = the_time('Y'); return $year; } add_shortcode('year', 'year_shortcode');
This brings the current year into the page but it sits at the top of the div rather than inline with the text. I’m wondering if the_time is being echoed despite the fact I used return? Can I use &echo=0 somewhere?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Creating a Year shortcode’ is closed to new replies.