How to add checkbox in existing settings page
-
Hi,
I’m trying to ad a checkbox to activate easily my maintenance page plugin.
I’m trying to put it in Settings -General page.
I have writted the following code:
function maintenance_options() { add_settings_section("maintenance_section", "Maintenance Options", "maintenance_options_content", "general"); add_settings_field("maintenance_field", "Activate Maintenance Mode", "maintenance_form_element", "general", "maintenance_section"); register_setting("maintenance_section", "maintenance_field"); } function maintenance_options_content() { echo "Maintenance settings section"; } function maintenance_form_element() { ?> <input type="checkbox" id="maintenance_field" name="maintenance_field" value="1" ' . checked(1, get_option('maintenance_field'), false) . '/> Checked to activate maintenance mode <?php } add_action("admin_init", "maintenance_options");
But When I checked it and save saettings this is not saved.
How can I realy add my new settings into this page ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to add checkbox in existing settings page’ is closed to new replies.