i am struggling with a simple code !

Support MB Group i am struggling with a simple code !Resolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19452
    sofdesignesofdesigne
    Participant

    Hi,

    i am just trying to understand why the field within a group is not showing, i think this will need a special code ! i searched everywhere and couldn't find the solution!

    here is my code: the first line shows normally the value, but the second doesn't show the value for another field within a group

    <?php
    echo rwmb_get_value('select_u6xr9smqot_k9abafij1m');
    
    echo rwmb_get_value('group_b30kbpp4roh_select_u6xr9smqot');
    ?>

    i copied the id from inspector

    thanks for your help

    #19454
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The value returned when getting the field group is an array, so you need to loop over the array by using foreach. Please follow this documentation to know how to display the group value
    https://docs.metabox.io/extensions/meta-box-group/#getting-sub-field-value

    #19473
    sofdesignesofdesigne
    Participant

    Thanks alot,

    here is my working code

    <?php
    $group_value = rwmb_meta( 'group_b30kbpp4roh' );
    
    $value = isset( $group_value['select_u6xr9smqot'] ) ? $group_value['select_u6xr9smqot'] : '';
    echo $value; // Display sub-field value
    ?>
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.