HI I'm making a metabox plug for wordpress and get a problem:
when getting the info from the meta box (metabox has a text area and a radio) I use:
foreach ($rian_meta_box['fields'] as $field) {
$meta = get_post_meta($post->ID, $field['id'], true);
switch ($field['type']) {
case 'radio':
*some code, get the radio value and put in a variable $aaa*
break;
case 'textarea':
*some code, and after I should use the $aaa variable with his value of the radio case*
break;
I tried but in the textarea case the variable is empty how I should do to pass it? Thanks!
I dont exactly know the scenario in which you are trying to implement this but 'switch-case' is a bad idea for this.
I see you assign value to $aaa under case radio - but then there is a break statement which breaks out of the switch case loop, so the textarea case never gets executed.
simply try 'if-then' statement
if (val of radio button is something) then $aaa = something; textarea value = $aaaa;
HTH
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.