I guess in the meantime you figured in out already. Though I want to share my experience since I faced the same problem and it might be useful for others.
In my case I just got the reference to the options wrong when creating the HTML code for the input-elements.
So since WordPress suggests to have one option saving an array of values that are the actual settings of your plugin/theme/whatever, you’ll problaby have something like this somewhere:
(Note: I will use plugin_config
where you you have Settings Name
, Rick.)
add_option('plugin_config', array(
'val1' => 1,
'val2' => 2'
));
Then in addition to registering the settings somwhere you will have registered the corresponding fields to enter values for the section, like this:
add_settings_field('val1_field', 'Field Label:', 'creat_html_callback', 'settings_page_slug_name');
Now the intresting part; when defining the html code, you have to set the name of the field in a way that wordpress can associate the corresponding post value of the request to the correct array position of the option plugin_config
(your Settings Name
!). So here is the callback referenced in add_settings_field
before
public function creat_html_callback() {
$option = get_option('plugin_config');
echo '<input type="text" id="val1Field" name="plugin_config[val1]" size="10" value="'.$option['val1'].'"/>';
}
The essentiell part for me was name="plugin_config[val1]"
. The name of the html-input-element must be the same as the registered (register_setting
!) option/setting or the name of the option together with the array index of the value corresponding to the input field.
Of course this seems clear and easy to see. Bit I think whith all those slug-names and references you can get easily confused especially when following a tutorial like this.