I am registering sidebars and sidebar widgets.

The theme currently supports two sidebars. Primary and Secondary.

add_action('widgets_init', array($this, 'add_sidebars'), 10, 2);

public function add_sidebars(){
        'name' => 'Primary Sidebar',
        'id' => 'mbe-sidebar-primary-sidebar',
        'description' => '',
        'class' => 'mbe-sidebar',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>'
        'name' => 'Secondary Sidebar',
        'id' => 'mbe-sidebar-secondary-sidebar',
        'description' => '',
        'class' => 'mbe-sidebar',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>'

Then I add all the preset widgets (post objects from a post type) as an available sidebar widget.

private function add_sidebar_widgets(){
    global $mbe_content;
    $widgets = $mbe_content->get_content('archive', 'mbe-sidebar-widgets');
    foreach($widgets as $widget){
            array($this, 'display_widget'),
                'description' => 'Sidebar Widget'

public function display_widget($args, $params){
    echo 'widget';

I have also set those sidebar widgets as active widgets in the primary sidebar. Now for example, at a theme level, If I wanted to just use a dynamic sidebar...

} else{

It show's "widget" from my widgets, but that's where the output for my widgets will occur. So that doesn't matter. The point is, the dynamic sidebar is working, and I can see my widget outputter.

A question I'm having is, how come if I add a simple default WordPress widget to the sidebar, it doesn't output anything on the sidebar? It's like it doesn't even exist or something.

How can I get my widgets to output on the sidebar, while still allowing the default sidebar widgets provided by WordPress to output on the sidebar as well?

I originally thought it was my function display_widget() So I tried getting all widgets, looping through them, then calling the_widget() on each of their widget ID's, but then I'm getting errors about that widget not being found, blah blah.

  • What is the right way to automatically display each of the active sidebar widgets? using dynamic_sidebar() Commented Mar 5, 2013 at 17:15
  • Does all of your code appear in your functions.php file?
    – Ryan
    Commented Mar 6, 2013 at 22:12
  • The sidebar and widget code is fired on the action: widgets_init, the call for dynamic_sidebar() is fired on the action: template_redirect to another custom hook in the theme's sidebar.php file. Commented Mar 11, 2013 at 19:29
  • I am not sure what you're question is. WordPress doesn't populate sidebars with any widgets, so far as I am aware. Your theme might though.
    – s_ha_dum
    Commented Dec 1, 2013 at 17:59

1 Answer 1


Check your template file from your theme. There may be some widgets being added in there manually if no other widgets are enabled.

If that's the case modify the conditional statement in your sidebar template so your widgets are output after the defaults set there.

@s_ha_dum basically got to the bottom of it.

Your Answer

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

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