Archived topic
Make shortcode (year) work in an GP Element
3 replies · Started by scometamus on March 15, 2023
Dear GP-team,
I used this code in the functions.php to make the "year shortcode" work in an individual html block:
/* Add shortcode for year */
function year_shortcode () {
$year = date_i18n ('Y');
return $year;
}
add_shortcode ('year', 'year_shortcode');
This works perfect. But as soon as I add the code [year] to my element hook, it does not get translated to the current year; so doesn't work.
Is there a solution to this?
Hi there,
it's better to use a block element - site footer, you don't need a custom function for the year, you can use GP's built-in template tag {{current_year}} in the site footer element.
Fantastic! Best theme/plugins, best support. Thanks!
Glad to hear that :)