Fatal error: Call to a member function check_capabilities() on a non-object

I’ve written this code in functions.php to add a section to my theme personalization.
But when I want to open “localhost/wordpress/wp-admin/customize.php?theme=eye-theme” to see my result, I see this error:

Fatal error: Call to a member function check_capabilities() on a non-object in C:xampphtdocsxamppwordpresswp-includesclass-wp-customize-control.php on line 233

Read More

This is my functions.php:

<?php

function eyetheme_register_theme_customizer($wp_customizer) {

    $wp_customizer->add_section(
        'eyetheme_display_options',
        array(
            'title'     => 'Display Options',
            'priority'  => 200
        )
    );

    $wp_customizer->add_setting(
        'eyetheme_link_color',
        array(
            'default'   => '#000000',
            'transport' => 'postMessage'
       )
    );

    $wp_customizer->add_control(
        'eyetheme_link_control',
        array(
            'section'   => 'eyetheme_display_options',
            'label'     => 'Link Color',
            'type'      => 'text'
       )
    );

}
add_action('customize_register', 'eyetheme_register_theme_customizer');

Related posts

Leave a Reply

1 comment

  1. You need to update $wp_customizer->add_setting() method and “settings” parameter in the arguments for $wp_customizer->add_control().

    i.e. In your example,

    $wp_customizer->add_setting(
      'link_color',
      array(
        'default'   => '#000',
        'transport' => 'postMessage'
      )
    );
    $wp_customizer->add_control(  
      'eyetheme_link_control',  
      array(  
        'section'   => 'eyetheme_display_options',  
        'label'     => 'Link Color',  
        'type'      => 'text',  
        'settings'  => 'link_color'  
      )
    )    
    

    Try this code…