Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Lars Hansen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Lars Hansen
Front End Web Development Techdegree Graduate 19,694 Points

Problems with the wp customizer

Hey There.

I am building a childtheme for the llorix-one-lite theme. I am trying to set up a simple header through the customizer in WordPress. I am new at PHP and WP developing.

When I try tro access the customizer I get the following error code: 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

"Call to member function ´add_setting()´ on unknown". What does this mean? Is the ´$wp_customize´ object unknown? Anyway, 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_customize->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'); ´´´

Thanks