You’d probably be best to use add_settings_field
and add_settings_section
…
But in any case, save_testimonials
is your validation / save callback function. It is given the data from the form and its job is to check it and then return the validated options. You shouldn’t be touching $_POST
or $_REQUEST
– that’s the point of the settings api.
save_callback{$array_of_data_from_form){
//Validate the $array_of_data_from_form
$validated=array()//Your settings array after validation
return $validated;
}`
But it will only recieve data with input name option_testimonials
as registered in your register_setting
. So your input fields will need names like option_testimonials[testimonial]
and option_testimonials
.
Best practise dictates that you should prefix your option names (option_testimonials
is a bit too generic).
As far tutorials go concerning the settings API you can’t go far wrong with this post.