3

I'm having some trouble with my widgets. I've registered widget areas correctly; as the widgets are showing up in the "Appearance" menu. However widgets aren't showing up in the Customizr section of WP; getting this error:

There are no widget areas currently rendered in the preview. Navigate in the preview to a template that makes use of a widget area in order to access its widgets here.

I've tried the solutions mentioned here: Widgets not displaying in theme customizer and here Widgets Section not displaying in theme customizer but had no luck.

My code is:

register_sidebar(array(
            'name' => 'Sidebar Widgets',
            'id' => 'sidebar-widgets',
            'before_widget' => '<section class="widget">',
            'after_widget' => '</section>',
            'before_title' => '<h4>',
            'after_title' => '</h4>'
        ));

<?php if ( is_active_sidebar( 'sidebar-widgets' ) ) : ?>
        <?php dynamic_sidebar('sidebar-widgets'); ?>
        <?php endif; ?>

Running WordPress 4.4.2.

I've tried the following things: 1. Tried dynamic_sidebar in different templates (header, front-page, index). 2. Tried navigating to different pages as suggested, no luck 3. No console errors 4. Tried theme on a different WordPress installation, no luck 5. Tried another theme, widgets working

Any other code I can add to this question to help troubleshoot?

  • 2
    where/when do you register the sidebar? where do you display it? – Mark Kaplun Feb 12 '16 at 12:28
  • any errors in the console? customizer is mostly javascript, if there is a conflict or error the widgets section may not load... – majick Feb 12 '16 at 12:53
  • Are you sure this answer is not your issue? – TheDeadMedic Feb 12 '16 at 13:00
  • @MarkKaplun, I've tried it in the sidebar, front-page, even added it in the header. No luck. – Hiriji Feb 12 '16 at 17:08
  • @majick Nope no errors in the console – Hiriji Feb 12 '16 at 17:09
2

The customizer needs the sidebar to be "displayed" in order to detect its existence on the page. In your code you display the sidebar only if it is "active" which means that it has at least one widget in it, otherwise when no widgets are included it is not displayed and therefore the customizer can not detect it.

Don't check for sidebar "activity", the display_sidebar should output empty div or a like if no widgets exist in it so no real point in preventing its execution.

  • Thanks Mark, unfortunately removing the if statement did not solve my problem. Even if I call it just via <?php dynamic_sidebar('sidebar-widgets'); ?> I still have no luck. It's still in Appearance but not in Customizer. – Hiriji Feb 12 '16 at 17:51

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.