0

I'm trying to add a footer area to wordpress so I can drop widgets and things there. I see my footer area in the admin section, but if I add a text (or any other) widget and then save it, nothing shows up on the footer. If I refresh the page, the widget that I dragged to the right in my footer area is no longer listed there.

I checked the network requests and there aren't any errors that I'm seeing. Did I miss a step?

footer.php contains:

<?php
get_sidebar('footer_widget_area');
wp_footer();
?>

functions.php contains:

// Register widgetized areas
function theme_widgets_init() {
    // Area 1
  register_sidebar( array (
  'name' => 'Primary Widget Area',
  'id' => 'primary_widget_area',
  'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  'after_widget' => "</li>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ) );

    // Area 2
  register_sidebar( array (
  'name' => 'Secondary Widget Area',
  'id' => 'secondary_widget_area', 
  'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  'after_widget' => "</li>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ) );

    // Footer
  register_sidebar( array (
  'name' => 'Footer',
  'id' => 'footer_widget_area', 
  'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  'after_widget' => "</li>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ) );
} // end theme_widgets_init

add_action( 'init', 'theme_widgets_init' );

Update: It's not just the new widget area I can't add widgets to, it's all of them.

2
  • have you checked for javascript errors in console?
    – Milo
    Jul 2, 2013 at 17:09
  • @Milo Yes, unfortunately there's nothing there either.
    – Ben
    Jul 2, 2013 at 17:29

2 Answers 2

1

You are using get_sidebar incorrectly. That function "Includes the sidebar.php template file from your current theme's directory." And if you include a parameter, it loads a file matching that parameter name, not a sidebar of that name.

If a name ($name) is specified then a specialized sidebar sidebar-{name}.php will be included.

What you want is dynamic_sidebar instead.

dynamic_sidebar('footer_widget_area');
5
  • +1 Thanks for pointing that out... though it didn't solve the issue on the admin side.
    – Ben
    Jul 2, 2013 at 15:57
  • I can't duplicate that admin side error. Using the code in my answer plus your code, things work fine for me.
    – s_ha_dum
    Jul 2, 2013 at 16:01
  • Try your code with all plugins disabled, and using a default theme. You'll have to edit the theme to test it but it should be OK since this is temporary debugging and can be overwritten on update.
    – s_ha_dum
    Jul 2, 2013 at 16:10
  • It works with the default theme, doesn't work with mine. I'll dig through their theme and see if any of their code is different...
    – Ben
    Jul 2, 2013 at 16:53
  • Everything I've done is consistent with the 2012 theme. Any other ideas on what could be causing the issue?
    – Ben
    Jul 2, 2013 at 16:59
0

I think that using dynamic_sidebar you should actually be calling the index-order. Since dynamic_sidebar is supposed to be this:

dynamic_sidebar( $index ); 

So if you have 3 sidebars, then it should be:

dynamic_sidebar( 'sidebar-3' );
1
  • $index is name or ID field of the registered sidebar, not position.
    – Milo
    Jul 2, 2013 at 17:09

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.

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