person in black and white t-shirt using computer

How to build WP Customizer elements

Four basic steps to use as code developer to customize your WP theme.
  • Create customizer wrapping function
  • Add section code
  • Add setting code
  • Add setting control

Step 1: Create customizer wrapping function

In functions.php add the following code;

function prefix_customize_registration( $wp_customize ) {
    // Your code will go here...
}
add_init('customize_registration', 'prefix_customize_registration');

Step 2: Add section code

Copy the following code inside wrapping function. This code tells WordPress to create a section for Customizer.

$wp_customize->add_section(
   'prefix_major_settings',
    array(
        'title' => esc_html__( 'Major Settings', 'prefix' ),
        'priority' => 10,
    )
);

Your wrapping function should look like this:

function prefix_customizer_registration( $wp_customize ) {
    $wp_customize->add_section(
       'prefix_major_settings',
        array(
           'title' => esc_html__( 'Major Settings', 'prefix' ),
           'priority' => 10,
        )
    );
}

Posted by darthsarden

Leave a Reply