I am using get_post_meta()
to retrieve a custom meta field value from a given post.
The custom meta box has a parent checkbox which has 3 child checkboxes. I want to get the values of both parent and child.
Parent checkbox Enable Protection for this post
Child checkboxes: (a) Level 1 (b) Level 2 (c) Level 3
here is the screenshot of the metabox. https://www.screencast.com/t/7fA19sCoe2yD
The code I am using is:
$meta = get_post_meta( '8142', '_key_value', true );
foreach( $meta as $m ){
echo $m['protect'];
echo $m['selectedlevels'];
}
But it only echo the $m['protect']
which is also the parent checkbox. How can I output its child checkboxes too?
if I var_dump
, it returns the following value:
array(2) { ["protect"]=> bool(true) ["selectedlevels"]=> array(1) { [0]=> int(2) } }
Any help would be highly appreciated.
thanks in advance :)
var_dump()
shows.