get taxonomy term name from cloneable group

Support MB Group get taxonomy term name from cloneable group

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33414
    kapitanpejsek@gmail.com[email protected]
    Participant

    Hi,
    I´m trying to output taxonomy term name instead of term ID which appears on output when pulling nested taxonomy data in Oxygen (unluckily there is no option to choose to output a term name instead of an ID), so I thing some custom PHP might help here.
    This is the code I´m using

    <?php
    
    $group_values = rwmb_meta( 'cfa-group_zavodni_den' );
    if ( ! empty( $group_values ) ) {
        foreach ( $group_values as $group_value ) {
            $value = isset( $group_value['cfa-trat'] ) ? $group_value['cfa-trat'] : '';
            echo $value; // Display sub-field value
            
        }
    }
    
    ?>

    This code outputs the word "array" on the frontend.
    I´m obviously no PHP wizard here. I need a little push so I can mine $value variable and pull term name out of it.
    Thanks for help

    #33424
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The returning array means you need to use another loop to iterate through elements of the array to output the value.

    To get the info of a term ID, field taxonomy in a group, you can use the WordPress function get_term(). Refer to this documentation https://docs.metabox.io/extensions/meta-box-group/#sub-field-values

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.