0

I have registered a sidebar and I use it on all of my pages. For some reason the customizer doesn't recognise it.

Have I done something wrong?

Here's my code:

functions.php

function registerSidebar() {
    register_sidebar( array(
        'name' => 'Main sidebar',
        'id' => 'main-sidebar',
        'description' => 'Main sidebar on the left.',
        'before_widget' => '<div id="%1$s" class="widget flex-column %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h5 class="widgettitle font-weight-bold">',
        'after_title' => '</h5>'
    ) );
}
add_action( 'widgets_init', 'registerSidebar' );

sidebar.php

dynamic_sidebar( 'main-sidebar' );

Then I just include my sidebar in the header.php file, like this:

get_sidebar();

Here's an image of the message I get:

problem

  • Are there any JS errors in the console? – Weston Ruter Nov 24 '17 at 3:55
0

I found out what the problem was.

I were using jQuery in the wrong way, which made the customizer fail.

This is how you should enqueue a script with jQuery:

function my_theme_scripts() {
    wp_enqueue_script( 'my-great-script', get_template_directory_uri() . '/js/my-great-script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );

See more on this page.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.