Support

Account

Home Forums Front-end Issues Display both value & label of select field with different methods

Solving

Display both value & label of select field with different methods

  • Hi,

    I have a select field called rating_total. It’s return format is set to label. For simplicity, its values are being displayed in the front end through the shortcode:

    [acf field="rating_total"]

    However, in one place I want to return the value (as opposed to the label) of that field. I want to use PHP for this and I tried all snippets I found in the documentation or forums – but none worked. They either kept showing the label of the selected option or even returned the field name “Rating total”.

    Can I even display the value of this field with PHP despite the return format being set to label (not array or value)?

  • Solved – I found the format_value parameter

  • How did you make it happen? I am trying to make things work with shortcodes, I will place them in the design, so that the web owner WON”T break the site.

    My short code is [acf field="contact"]

    It will be inside the design of a box for example.

    Thank you,

  • Hi, I actually only managed with PHP, not shortcodes:

    <?php the_field('rating_total',false,false); ?>

    This works for me

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.