How to Add Select Option to the Customizer wordpress page

Suppose we need to Add Select Option In Customize Page Of WordPress .Wordpress Provide Predefined Hooks to Perform this Action here we need to DO Three Things first Call The Customize Registration hook by using add_action than Add Section and Then Add Controler Following Code is Given Below

function add_company_customize_register( $wp_customize ) {
 
 
  $wp_customize->add_section('mytheme_options', array(
    'title'    => __('Company', 'basicbs'),
    'priority' => 120,
  ));
 
  $wp_customize->add_setting('com_1', array(
    'default'        => 'uncategorized',
    'capability'     => 'edit_theme_options',
  ));
  $wp_customize->add_control( 'com_1', array(
    'settings' => 'com_1',
    'label'   => 'Select',
    'section' => 'mytheme_options',
    'type'    => 'select',
                    'choices' => array(
    'value1' => __( 'company' ),
    'value2' => __( 'Value 2' ),
    'value3' => __( 'Value 3' ),
  ),
  )); 
}
add_action( 'customize_register', 'add_company_customize_register' );

To Call Above Data in the Theme we need to use

 get_theme_mod( 'com_1');

Add a Comment

Your email address will not be published. Required fields are marked *

17 − fifteen =