I am developing a plugin, but I am clearly missing something.
My options for the check boxes I have created are saving, but I have also created a dropdown menu. The drop down menu doesn't save my selection for some reason. Thoughts?
//add for settings page
add_settings_field("add-sizing", "Icon size", "add_sizing_function", "rcktcld-social", "admin_settings_section");
//register
register_setting("admin_settings_section", "add-sizing");
<?php function add_sizing_function() { ?>
<select name="add-sizing">
<option value="60" <?php selected( "add-sizing", 60 ); echo esc_attr( __( 'Select page' ) ); ?> >X-Large</option>
<option value="48" <?php selected( "add-sizing", 48 ); echo esc_attr( __( 'Select page' ) ); ?> >Large</option>
<option value="32" <?php selected( "add-sizing", 32 ); echo esc_attr( __( 'Select page' ) ); ?> >Medium</option>
<option value="24" <?php selected( "add-sizing", 24 ); echo esc_attr( __( 'Select page' ) ); ?> >Small</option>
</select>
}
They are probably saving fine, but you're not using the selected
function properly: it compares two values for equality, and "add-sizing"
is never equal to a number.
You'll want to replace the first argument with the actual option value, like so:
$add_sizing_setting = get_option( 'add-sizing' );
...
<option value="60" <?php selected( $add_sizing_setting, 60 ); .....
<option value="48" <?php selected( $add_sizing_setting, 48 ); .....
...