Settings API with arrays example

Short answer: your name attribute values must use the schema option_name[array_key]. So, when you use … <input name=”option_name[key1]”> <input name=”option_name[key2]”> … you get an array as option value in your validation function: array ( ‘key1’ => ‘some value’, ‘key2’ => ‘some other value’ ) PHP does that for you, this is not a WordPress feature. … Read more

Extend WP_Customize_Control with Multiple Field Control

I was able to achieve my goal not by creating a custom control with multiple input fields but by creating creating a custom control which still accepted a single input, but would display inline with other controls. Here’s the custom control for an inline numerical input: class Customizer_Number_Inline_Control extends WP_Customize_Control { public $fieldwidth=”text”; public $type=”number”; … Read more

Option doesn’t save

An option is a meta information saved in the database as a string. An array is a memory specific variable that has its own characteristics. But to every problem there is a workaround: $myoption = json_encode($the_array(); add_option(‘myoption’, $myoption, ”, ‘yes’); Now to fetch it: $myoption = json_decode(get_option(‘myoption’)); Voila. When saving the option I converting to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)