I'm currently working on my first in-depth custom template for Wordpress, utilizing the functionality of the customizer.
I am able to create options and also save them but somehow i am unable to push them to the page itself. The code i'm using:
//Do we want our template to be boxed or wide?
function cbTheme_customize_register($wp_customize){
// =============================
// = Add section =
// =============================
$wp_customize->add_section('cbTheme_general_settings', array(
'title' => __('General Settings', 'cbTheme'),
'description' => 'Determines wether your site is boxed, or has 100% width',
'priority' => 10,
));
// =============================
// = Add setting =
// =============================
$wp_customize->add_setting('cbTheme_site_settings[sitewidth]', array(
'default' => 'value1',
'capability' => 'edit_theme_options',
'type' => 'option',
));
$wp_customize->add_control('cbTheme_site_width', array(
'label' => __('Site width', 'cbTheme'),
'section' => 'cbTheme_general_settings',
'settings' => 'cbTheme_site_settings[sitewidth]',
'type' => 'radio',
'choices' => array(
'value1' => 'Wide',
'value2' => 'Boxed',
),
));
}
add_action( 'customize_register', 'cbTheme_customize_register' );
I am using this in my header.php(first lines) to try and retrieve the options (as they do save).
//GET ALL SETTINGS FROM CUSTOMIZER
function cbTheme_customize_css($wp_customize){
$sitewidth = get_theme_mod('cbTheme_site_settings[sitewidth]');
}
add_action( 'wp_head', 'cbTheme_customize_css');
Any advice/feedback on this? I assume the faulty code is the last part. I tried following the codex, but i am lost at the data retrieval process.