How to output group and post meta value

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email

Code on metabox.config.php file


array(
      'id'      => 'car_year_lists_x',
      'type'    => 'group',
      'title'   => 'Year Data',
      'desc'    => 'Add Availibility For Cars',
      'button_title'   => 'Add New Year',
      'fields'  => array(

        array(
          'id'    => 'mb_car_year_details_av',
          'type'  => 'text',
          'title' => 'Car Model & Year',
        ),    
      ),
    ),

NOW CODE ON THE OUTPUT PHP FILE


<?php
$meta_data = get_post_meta( $post->ID, 'mbhouse_project_meta', true );
$meta_groups = ( ! empty( $meta_data['car_year_lists_x'] ) ) ? $meta_data['car_year_lists_x'] : '';
?>

<?php if( !empty($meta_groups) ): ?>
    <pre>
       <?php foreach($meta_groups as $meta_group): ?>
       <?php echo $meta_group[ 'mb_car_year_details_av' ]; ?>
       <?php endforeach; ?>
    </pre>
<?php endif; ?>

Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert