Home Forums Front-end Issues Display Labels of Checkbox Field


Display Labels of Checkbox Field

    • xaibi

    • November 15, 2019 at 7:58 am

    I am trying to create an advanced search. So I want to grab all checkbox fields. I don’t want to display it in a post. So I just want to grab the labels of the specific field.

    I am trying to make a dropdown to show the labels. So in this, it will grab auto all labels by. Is it possible?

    <td><select style="height:30px;">
    <option value="">Select City</option>
    <option value="">label 1</option>
    <option value="">label 2</option>
    <option value="">label 3</option>
    • xaibi

    • November 23, 2019 at 7:43 am

    Hello, any help with this???

    $field = get_field_object('field_XXX'); // use field key
        <option value="">Select City</option>
          foreach ($field['choices'] as $v => $l) {
            ?><option value="<?php echo $v; ?>"><?php echo $l; ?></option>
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.