Support

Account

Home Forums General Issues showing checkbox values

Helping

showing checkbox values

  • hi, I have a checkbox custom field with images for the values. The label is “Maskapai” and the name is “maskapai”
    the code that I’m using:

    <?php
    
    // vars	
    $maskapai = get_field('maskapai');
    
    // check
    if( $maskapai ): ?>
    <ul>
    	<?php foreach( $maskapai as $maskapai ): ?>
    		<li><?php echo $value; ?></li>
    	<?php endforeach; ?>
    </ul>
    <?php endif; ?>
    ?>

    but it didn’t show anything. if I’m using

    $value = get_field( "text_field" );
    
    if( $value ) {
        
        echo $value;
    
    } else {
    
        echo 'empty';
        
    }

    I’ll get a text message “Array” something instead..

  • You can’t return $maskapai from the same variable. Try below. You may also need to adjust it depending on how you set up the field output.

    <?php
    // vars	
    $maskapai_list = get_field('maskapai');
    
    // check
    if( $maskapai_list ): ?>
    <ul>
    	<?php foreach( $maskapai_list as $maskapai ): ?>
    		<li><?php echo $maskapai; ?></li>
    	<?php endforeach; ?>
    </ul>
    <?php endif; ?>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.