1

im trying to save different value of radio buttons on same name, it works and was able to make checked appear if the correct value is saved.


As you can see on the screenshot ABOVE (which is taken on view-source:), it the correct selected input is CHECKED already however even if it's check you can see on the screenshow BELOW that it doesn't display as checked.

enter image description here


It's already checked but not displaying , i dont know

  • Can you inspect the css of the radio button? – Tamil Selvan C Feb 23 '17 at 1:48
  • I inspect the css of the radio button too, i tried selecting 1 frm the radio button and the checked icon appear. But on page load, the checked icon doesn't appear on the radio input. – Archangel17 Feb 23 '17 at 2:57
2

In the WordPress back-end you have to use checked="checked" (stricter XHTML), because the CSS will not be applied otherwise:

<input type="radio" name="colors" id="blue" checked="checked">

this is the CSS that applies the blue dot:

enter image description here

WordPress already provides a function for this checked()

<input type="radio" name="colors" id="blue" <?php checked( 'red', get_option( 'color' ) ); ?> />

so you dont have to do an If and echo.

1

I think you can Also try it checked="checked" some time issue with checked so just try it.

checked

Replace with

checked="checked"
0

Thanks a lot everyone for all your time! I really appreciate it!

I've finally found what's causing it to appear and it's because i forgot to remove the old sets of radio buttons with the same id as that on a different meta box.

I've finally fixed it! Thank you!

-1

Check if you have another group of input radio button with the same name be the issue. Just rename other groups of input radio button with different name, should resove the issue.

In your case name='seasons' should not be used for another radio button group.

Thanks,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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