How to create radio button in options page?
-
Call me stupid but I coudn’t figure out how to do it. For text input I would just:
<input type="text" name="option_name" value="<?php echo get_option( 'option_name' ); ?>" />
and then hook it into wordpress using register_setting(). I could then get its value thru get_option(‘option_name’). How should I do that with radio buttons?
All im looking for is simple “yes” / “no” radio buttons.
I can’t seem to figure out how to register my yes / no options in db and how to get its value thru get_option(‘option_name’).
register_setting( 'baw-settings-group', 'chooseyes', 'yes' ); register_setting( 'baw-settings-group', 'chooseno', 'no' ); <input name="chooseyes" type="radio" value="0" <?php checked( '0', get_option( 'chooseyes' ) ); ?> /> <input name="chooseno" type="radio" value="1" <?php checked( '1', get_option( 'chooseno' ) ); ?> />
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to create radio button in options page?’ is closed to new replies.