admin管理员组

文章数量:1331927

I am building a new theme from scratch as part of my auto learning process. I have added the lines to register a new widget area in functions.php as follow:

<?php
/**
 * Including the widget area.
 */
function theme_widget_areas_init() {
    register_sidebar( array(
        'name'          => _('Topbar Left'),
        'id'            => 'topbar-left',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => '',
    ) );
}
add_action( 'widgets_init', 'theme_widget_areas_init' );

Also I have set and specific area within my index.php file for the sidebar.

<?php if (is_active_sidebar('topbar-left')) :?>
    <?php dynamic_sidebar('topbar-left'); ?>
<?php endif ?>

Finally the issue is that my widget perfectly appears on the Appearance/Widget area and is active with a text widget just as a test, also the front-end side shows the widget with its content. However the Customize area does not show the widget area and instead displays the already pretty common text:

Your theme has 1 widget area, but this particular page doesn’t display them.

Well, so for consideration:

  • Yes, the template includes the wp_head() and wp_footer() tags.
  • Yes, I already checked the php error log and seems ok.
  • Yes, I am in the index in the Customize and is the page I placed the sidebar on, I know it because it shows me the actual widget but on the view, not in the options though.
  • I also have tried the Health Checker plugin and it showed Good and did not fix the issue either.

I am building a new theme from scratch as part of my auto learning process. I have added the lines to register a new widget area in functions.php as follow:

<?php
/**
 * Including the widget area.
 */
function theme_widget_areas_init() {
    register_sidebar( array(
        'name'          => _('Topbar Left'),
        'id'            => 'topbar-left',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => '',
    ) );
}
add_action( 'widgets_init', 'theme_widget_areas_init' );

Also I have set and specific area within my index.php file for the sidebar.

<?php if (is_active_sidebar('topbar-left')) :?>
    <?php dynamic_sidebar('topbar-left'); ?>
<?php endif ?>

Finally the issue is that my widget perfectly appears on the Appearance/Widget area and is active with a text widget just as a test, also the front-end side shows the widget with its content. However the Customize area does not show the widget area and instead displays the already pretty common text:

Your theme has 1 widget area, but this particular page doesn’t display them.

Well, so for consideration:

  • Yes, the template includes the wp_head() and wp_footer() tags.
  • Yes, I already checked the php error log and seems ok.
  • Yes, I am in the index in the Customize and is the page I placed the sidebar on, I know it because it shows me the actual widget but on the view, not in the options though.
  • I also have tried the Health Checker plugin and it showed Good and did not fix the issue either.
Share Improve this question edited Jul 17, 2020 at 3:48 Oscar Contreras asked Jul 17, 2020 at 3:34 Oscar ContrerasOscar Contreras 213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Thanks to the wordpress forums, some grateful one just helped me finding the answer. So If you come here looking for a solution. Please first try the options I put in the post before, they did not work for me but they did for other users, so give them a try first.

If for some reason, just like me, you still have problems with the Customizer then open your console in google chrome and check for errors in javascript because as Joy suggested it to me here the Customizer has a lot of JS and specially uses jQuery.

To summarize, I could fix the problem by removing my calling to jQuery for Bootstrap in my theme and let it just use the default one in wordpress. So far, there has been no problem with the CSS library so I hope this is done.

本文标签: customizationCustomize section does not show my widget areas