i came across this today “Save metabox with multiple checkbox array” which helped me a lot, but i can’ figure out how to retrive both key and value on the frontend let say we have:

$elements = array(
    'apple-product'  => 'Apple',
    'orange-color' => 'Orange',
    'banana-fruit' => 'Banana'

i would like to be able to display each checkbox value and key which are checked on each post.

        $args = array(
         'post_type' => 'news'
         $repeat_loop = new WP_Query( $args ); if ( $repeat_loop->have_posts() ) : while ( $repeat_loop->have_posts() ) : $repeat_loop->the_post();
         $meta = get_post_meta( $post->ID, 'elements', true ); 

         foreach ($meta as $key => $value) {
         echo "<li><strong>".$key."</strong> : "; ?><?php echo $value."</li>";
      <?php endwhile; 

Read more here: How do you retrive both key and value of checked boxes on the frontend for each post


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: