Custom Fields
Re-Envisioned
Support Meta Box Group How to get a label from a select_advanced field that is in a group field?

  • Creator
    Topic
  • #18023
    Resolved MartinJaneek
    Participant

    Hi,
    I have a group field in which I have a select_advanced field. How can I get label from the select_advanced field? I have a value, but i need a label.

    my current code:

    <?php
    $parts_name = rwmb_meta('group', $args = ' ', $post_id = $post->ID);
    foreach ($parts_name as $part_name) : 
                echo $part_name['item'];
    endforeach
    ?>

    group ID -‘group’
    select_advanced ID – ‘item’

    Thank you

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #18033
    Anh Tran
    Keymaster

    Hi Martin,

    The helper function doesn’t return labels for the field, but only values. You can get the label with this code:

    $parts_name = rwmb_meta( 'group' );
    $group_settings = rwmb_get_field_settings( 'group' );
    $select_settings = $group_settings['fields']['select_field_id'];
    foreach ( $parts_name as $part_name ) {
        $value = $part_name['item'];
        $label = $select_settings['options'][$value];
        echo $label;
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.

Newsletter

Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.


grid gear info copy caret-up caret-down trash