Custom Fields: check, save and update multiple Check Boxes in Meta Box
-
Hello,
I’m trying to add some meta boxes to custom post types.
In one of these meta boxes I wish to display posts from another post type in the form of multiple checkboxes inputs, each one having the value set to the ID of the corresponding post. I’ve accomplished that as you can see below.
The problem is that I would like to save all the values which will be selected as multiple values in one single custom meta filed (ie like comma separated values). My intention is to retrieve later these CSV to retrieve the IDs of the posts associated to these values.
My problem is that I don’t know how to accomplish that or how to save all the Check Boxes information – right now they’re not working…
I googled like crazy but couldn’t find a solution, so my last hope is in the community – thanks!
<php $args = array( 'post_type' => 'product', ) $ab_file_products = get_posts($args); foreach( $ab_file_products as $post ) : setup_postdata($post); $file_id = 'file_related_product[' . get_the_ID() . ']'; ?> <li> <input type="checkbox" name="<?php echo $file_id ?>" value="<?php echo get_the_ID() ?>" <?php if ( get_the_ID() == $file_id) echo 'checked="checked"'; else ''; ?> id="ab_file_product_<?php the_ID();?>" /> <label for="ab_file_product_<?php the_ID();?>" ><?php the_title(); ?></label> </li>
- The topic ‘Custom Fields: check, save and update multiple Check Boxes in Meta Box’ is closed to new replies.