WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use this code when create input box for post meta box:

<input type="text" name="<?php echo $name; ?>" id="x" value="<?php echo $value; ?>" />

Now I need to handle radio box which has 2 inputs with the same name:

<input type="radio" name="option" id="option-current" value="0" />
<input type="radio" name="option" id="option-custom" value="1" />

If use echo $name; and echo $value with radio type, post meta will have 2 value for one key, that makes the radio selection lost meaning.

How to get correct result from the radio type?

share|improve this question

Radio buttons should have the same name with different values if you want to group them together. I'd call them something that isn't option and not use the ID.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.