• Resolved HeroGreg

    (@herogreg)


    I’m creating a list of items on a page. For ex: Top 10 sports teams of 2015

    I have created a loop. In the loop I have a text field, and image field etc.

    Originally, I had used a text field to output the # in the list, the user would have to manually enter the # . My code looked like this (for this question I omitted the shortcode for the image field etc and left only the shortcode that outputted the field number)

    <?php
        $fields = CFS()->get('list-item-loop');
      ?>
            <? foreach ($fields as $field) : ?>
                <?= $field['list-item-number'] ?>
            <? endforeach ?>
    <?php } ?>

    This worked fine, however I decided that having a select field, rather than a text field, would be better since a user could choose the number from the list rather than manually input the number.

    I am wondering how to modify the above code to output the number chosen from the select field, because the code above does not work.

    https://ww.wp.xz.cn/plugins/custom-field-suite/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Matt Gibbs

    (@mgibbs189)

    Do a

    var_dump( $fields );

    to make sure you’re using the right field name. It’ll also show you what’s contained within the $fields array.

    Thread Starter HeroGreg

    (@herogreg)

    I figured it out earlier, here’s the code:

    <?php
        $fields = CFS()->get('item-field');
    ?>
        <? foreach ($fields as $field) : ?>
    
            <?= $field['list-item-title'] ?>
    
            <? foreach ($field['color'] as $colors => $label) :?>
                <? echo $colors ; ?>
            <? endforeach ?>
    
        <? endforeach ?>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Output 1 Select Value shortcode’ is closed to new replies.