Support

Account

Home Forums Backend Issues (wp-admin) How to: Loop through value and label

Solving

How to: Loop through value and label

  • I would like to select links from my custom field and display them in this format: <a href="$value">$label</a>.
    How can I loop through both value and label at the same time ?

    Best regards,

    Toni

  • Hi @slaughter77

    This depends on the type of field you are referring to. Can you please describe what field type you are using, and where the label / value come from?

    I would assume that you are using a select field and the label will come from the choices. If this is correct, you can see a code example of this on the select field’s documentation – http://www.advancedcustomfields.com/resources/field-types/select/

    Thanks
    E

  • Yes, I am using the select field.I need to loop throught multiple $value and $label values and display them as a list(url list).

    I am also struggling with adding custom fields to display on my single post and homepage/blogpage. I can’t seem to find where to add the code to display custom fields on both.

    Thank you for your time.

  • I figured how to display custom fields on both posts and homepage 🙂 so that’s not a problem anymore.

  • Hi @slaughter77

    Thanks for the update. Did you follow the code example on the linked tutorial I mentioned.

    How are you going with your code?

    Thanks
    E

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

The topic ‘How to: Loop through value and label’ is closed to new replies.