I am trying to set up a simple header through the customizer in WordPress. I am new at PHP and WP developing.
Here is my functions.php:
//add contact_info_header customizer
function wpl_customize_register( $wp_register ) {
//ALL sections, settings and controls will be added
$wp_customizer->add_setting( 'contact_header', array(
'default' => 'Giver Uforpligtende Tilbud',
'transport' => 'refresh'
) );
$wp_customize->add_control(
new WP_Customize_Text_Control( $wp_customize, 'Contact Heading', array(
'label' => __( 'Contact Heading', 'lorrix_one_lite_child'),
'section' => 'llorix_one_lite_contact_section',
'settings' => 'contact_header',
'type' => 'text'
) ) );
$wp_customize->get_section ('llorix_one_lite_contact_section')->transport = 'refresh';
}
add_action( 'customize_register', 'wpl_customize_register');
And my error code. I inly get this when accesing the front-end customizer:
"Fatal error: Uncaught Error: Call to a member function add_setting() on unknown in C:\xampp\htdocs\localwp.com\wp-content\themes\llorix-one-lite-child\functions.php:20 Stack trace: #0 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-hook.php(298): wpl_customize_register(Object(WP_Customize_Manager)) #1 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array) #2 C:\xampp\htdocs\localwp.com\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #3 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-customize-manager.php(734): do_action('customize_regis...', Object(WP_Customize_Manager)) #4 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-hook.php(298): WP_Customize_Manager->wp_loaded('') #5 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array) #6 C:\xampp\htdocs\localwp.com\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #7 C:\xampp\htdocs\localwp.com\wp-settings.php(470): do_action('wp_loaded') #8 C:\xampp\htdocs\localwp.com\wp-con in C:\xampp\htdocs\localwp.com\wp-content\themes\llorix-one-lite-child\functions.php on line 20"
To me it looks like it is having problems calling add_setting() on the $wp_customize object?
Thank you all for reading and answering.