CHAPTER 6 • Advanced Theme Usage 151
To populate the kihon_theme_settings() function, you first need to create a brand-new
section, your very own Footer Details box where all the settings will be located. This is done
with add_section(), like so:
// Add kihon_footer section footer settings
$wp_customize->add_section( 'kihon_footer', array(
'title' => 'Footer Details', // Title of section
'description' => "Customize your site\'s footer copy.", // Description
) );
Your section is called kihon_footer, and there are a number of parameters you can pass to
it should you want to, within the familiar array. Don’t bother with that now, though, as most
of the default values fit your needs, so the only thing you’re adding is a title and a description.
Next is the actual setting for your simple text box:
// Add setting for kihon_footer_copyright
$wp_customize->add_setting( 'kihon_footer_copyright', array(
'default' => '© '. get_bloginfo( 'name' ),
) );
The setting is named kihon_footer_copyright because I imagine most people will put a
copyright notice in the footer. add_setting() looks much like add_section(), and
there are a lot of possible parameters to pass. Stick with just a default value, which will be ©
and then the site name through get_bloginfo().
The final part is the control:
// Add control for kihon_footer_copyright
$wp_customize->add_control( 'kihon_footer_copyright', array(
'label' => 'Text in the footer',
'type' => 'text',
'section' => 'kihon_footer', // Add to section kihon_footer
) );
The control is connected to the setting, and as you no doubt have read from the array within
add_control(), there’s a label with some informative text. You’ve set the control to the
text type, which is a simple text input field. Finally, the control is added to the appropriate
section, kihon_footer in this case.
That’s it, actually. The whole function now looks like this:
// THEME SETTINGS
function kihon_theme_settings( $wp_customize ) {
// Add kihon_footer section footer settings
$wp_customize->add_section( 'kihon_footer', array(
'title' => 'Footer Details', // Title of section
'description' => 'Customize your site\'s footer copy.', // Description
) );