0

In my custom theme's function.php file, I have created a widget area:

function my_footer_widget_area() {
    $args = array(
        'id' => 'footer_widget_area',
        'class' => 'my_widget_footer',
        'name' => __('Footer Widget Area', 'mynamespace'),
        'description' => __('Widgets for the footer. The widget title will appear above the widget content. Leave the title blank to only display widget content.', 'mynamespace'),
    );
    register_sidebar($args);
}

Which is activated with

add_action('widgets_init', 'my_footer_widget_area');

The theme's sidebar.php file contains

if (is_active_sidebar('footer_widget_area')): ?>
    <div id="tertiary" class="footer-container" role="complementary">
        <div class="footer-inner">
            <div class="widget-area">
                <?php dynamic_sidebar('footer_widget_area');?>
            </div><!-- .widget-area -->
        </div><!-- .footer-inner -->
    </div><!-- #tertiary -->
        <?php else: ?>
        <!-- Time to add some widgets! -->
    <div id="tertiary" class="footer-container" role="complementary">
        <div class="footer-inner">
            <div class="widget-area">
  <!--  <p>footer sidebar  - not active</p>    -->
            </div>
        </div>
    </div>
<?php endif;

When the theme is activated, the widget area is active, but the widget area contains widgets.

How do I create the widget area with no widgets in that widget area? Are there default widgets assigned to a created widget area? If so, how do I disable those default widgets?

1
  • "but the widget area contains widgets" - then I guess the theme has already been activated before, but then deactivated, or that another theme which was active before, had a widget area with the same id (footer_widget_area), and those widgets were added to that widgets area? And remember that a plugin could also register a widget area with the same id. Have you checked those aspects and tried clearing your caches?
    – Sally CJ
    Feb 23 at 3:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.