You can use the customize_register action like this:
function my_customize_register( $wp_customize ) {
/* Just use the $wp_customize object and create a section or use a built-in
section. */
$wp_customize->add_section(
'my_section',
array(
'title' => 'My Section',
'priority' => 30,
)
);
/* Now you can add your settings ... */
$wp_customize->add_setting(
'my_options[my_first_option]',
array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
)
);
/* ... and link controls to these settings. */
$wp_customize->add_control(
'my_first_option',
array(
'label' => 'My First Option',
'section' => 'my_section',
'settings' => 'my_options[my_first_option]',
)
);
}
add_action( 'customize_register' , 'my_customize_register' );
You can use built-in sections or define your custom ones. Define your settings as you like and link controls to them.
The page Theme Customization API has a lot of useful code … but, because you asked for tips: Always set WP_DEBUG when you develop code for WordPress. You’ll see very often immediately the reason why something is not working as expected.