• Resolved yeshecan

    (@yeshecan)


    Hi,

    i need to add a suffix to a custom fields, eg for a surface: a flat of 85 m² (square meters).
    I’m using [pods field=”surface”]: is there an option to add a suffix?
    Eg [pods field=”surface” before=”Surface : ” after=” m²”]

    I believe it is possible with ACF for example.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support pdclark

    (@pdclark)

    See https://docs.pods.io/displaying-pods/magic-tags/display-filters-with-magic-tags/

    Define a formatting function using a Code Snippet plugin, plugin added to wp-content/plugins or wp-content/mu-plugins, or theme’s functions.php:

    <?php
    /**
    * Plugin Name: Format Surface Area
    */
    function fmt_area( $number ) {
    // Second argument is number of significant figures.
    $number = number_format( $number, 1 );

    // Replace '.0' with nothing.
    $number = str_replace( '.0', '', $number );

    // Output template, where %s is the variable placeholder.
    // @see https://www.php.net/manual/en/function.sprintf.php
    return sprintf(
    'Surface: %sm²',
    $number
    );
    }

    Then, if the function is named fmt_area, add fmt_area to the comma-separated list of allowed display callback functions near the bottom of Pods Admin > Settings, and use the callback function by adding its name after a comma in the magic tag, for example {@surface,fmt_area}

    Thread Starter yeshecan

    (@yeshecan)

    Hi,

    thank you, your solution is working!

    Regards
    Christophe

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.