radio button is checked but display not check

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

4 Answers
4

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.

Leave a Comment