• Resolved s84d

    (@s84d)


    I can get it to output all the values from a repeatable field by using this shortcode
    [pods field=’field_name’]

    Is there a way to specify which value to show, like output the third value only?

    • This topic was modified 1 year, 5 months ago by s84d.
Viewing 1 replies (of 1 total)
  • Plugin Support pdclark

    (@pdclark)

    Add a new function, item_three with a Code Snippets plugin or by adding the below code to a new folder/file.php in wp-content/plugins/

    <?php
    /**
    * Plugin Name: Item Three
    * Description: Display the third item in a list.
    */
    function item_three( $items ) {
    $key = 2; // Items are zero-indexed. 2 is 3.
    if ( array_key_exists( $key, (array) $items ) ) {
    return $items[ $key ];
    }
    return ''; // Blank if there is nothing.
    }

    …then add item_three to the comma-separated list labeled Display callbacks allowed near the bottom of Pods Admin > Settings

    The shortcode to display the third item of repeatable field field_name will now be:

    [pods]{@field_name,item_three}[/pods]
Viewing 1 replies (of 1 total)

The topic ‘Shortcode to display one item from a repeatable field’ is closed to new replies.