• Resolved Sun

    (@sunrv)


    Whenever I try to use the magic tags {@post_date} to show the publish date of my posts, I get the following formatting: 2024-12-16 11:15.

    I need it to be like “30 december 2024” instead, but I haven’t figured out how to change that formatting yet. The WordPress general settings have already been set up to use the desired format, but the Pods template won’t load that version in.

    Does anyone know how to change the standard date formatting to be like ‘j F Y’?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Paul Clark

    (@pdclark)

    There is an unreleased patch for this, but in the meantime, see https://docs.pods.io/code-snippets/date-format-output-filter-for-magic-tags/ for how to filter the output. For example:

    Create a function in theme functions.php, a new plugin, or a Code Snippets plugin:

    function date_to_jfy( $input_date ) {
    return date( 'j F Y', strtotime( $input_date ) );
    }

    Add the name of the function, date_to_jfy in the example above, to the list of allowed display functions near the bottom of Pods Admin > Settings in the security section.

    Use the formatting function on the magic tag with a comma and the function name: {@post_date,date_to_jfy}

    Generically:

    • Any magic tag can be filtered through any function added to the allow list.
    • The function must take one argument. The value will be the value of the magic tag.
    • The function must return text (a string), which will be displayed.
    • The syntax is {@name_of_field,name_of_function} — the field name followed by a comma and the function name.

    Display functions are usually custom, but any pre-defined function which receives one argument containing text and returns text can also be used if added to the whitelist.

    Thread Starter Sun

    (@sunrv)

    Hi Paul,

    Thanks for the reply, it worked almost perfectly! The only issue I have now is that it shows the month string in English, while the website language is Dutch. I set this up in the WordPress settings and the HTML language is also nl-NL.

    Is it possible to translate the month string accordingly?

    Plugin Support Paul Clark

    (@pdclark)

    date_i18n() with the same format as date()

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