Site logo

[Resolved] Make shortcode (year) work in an GP Element

Home Forums Support [Resolved] Make shortcode (year) work in an GP Element

Home Forums Support Make shortcode (year) work in an GP Element

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2568971
    scometamus

    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?

    #2568997
    Ying
    Staff
    Customer Support

    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.

    #2569035
    scometamus

    Fantastic! Best theme/plugins, best support. Thanks!

    #2569120
    Ying
    Staff
    Customer Support

    Glad to hear that 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.