logo

$25
Sidebar not saving widgets

I am using a sidebar system that is more complex that normal themes. My problem is that widgets are not saving. I am using the latest stable WP version and this theme is run on multiple blogs within the same multisite setup. The functions code can be found here:
http://pastebin.com/1f3diTxN.

I am looking for a second set of eyes to help me find the issue. Thanks so much. :)


Update: I failed to mention that the main widget area is saving the widgets which to me would suggest that my arrays are jacked up somewhere. Of course I could be wrong...

Matt Taylor | 08/05/10 at 2:14pm | Edit


(4) Possible Answers Submitted...

  • avatar
    Last edited:
    08/05/10
    2:17pm
    Pippin Williamson says:

    Does WP give you an error when trying to save the widget?

    • 08/05/10 2:19pm

      Matt Taylor says:

      No. Everything looks as normal.

    • 08/05/10 2:21pm

      Matt Taylor says:

      When the page is refreshed or navigated away from and then back to the widgets appear in the Inactive Widgets section.

    • 08/05/10 2:22pm

      Pippin Williamson says:

      If the widgets don't work in the default theme either, then it's no an issue with your coding. It's probably a plugin conflict. Deactivate all plugins and test.

    • 08/05/10 2:29pm

      Matt Taylor says:

      Just deactivated all plugins and removed mu-plugins folder, no changes.

    • 08/05/10 2:30pm

      Pippin Williamson says:

      Do no widgets save, or just some of them? Is the site running on a local WP install or on a live server?

    • 08/05/10 2:37pm

      Matt Taylor says:

      I failed to mention that the main widget area is saving the widgets which to me would suggest that my arrays are jacked up somewhere. Of course I could be wrong...

      No widgets save in any area outside of the primary sidebar, id: sidebar-widgetarea.

    • 08/05/10 2:38pm

      Pippin Williamson says:

      Do they save in other widget areas?

    • 08/05/10 2:39pm

      Pippin Williamson says:

      Oops, I mean do they save in the primary widget area?

    • 08/05/10 2:39pm

      Matt Taylor says:

      Just the primary area. Not in the other seven.

    • 08/05/10 2:41pm

      Pippin Williamson says:

      Create a new widget area by copying the code from the primary, then very carefully change the names. See if that area saves. If so, you have your problem solved.

    • 08/05/10 2:42pm

      Matt Taylor says:

      I have done that twice already. :/

    • 08/05/10 2:44pm

      Pippin Williamson says:

      Have you tried making another widget area with as few options as possible, to make the margin of error much less?

    • 08/05/10 2:45pm

      Matt Taylor says:

      Yes of course.

    • 08/05/10 2:48pm

      Pippin Williamson says:

      Have you tried running the theme on a different server? Perhaps on a local WP install? As Rashad said, it might be a problem with your hosting config.

    • 08/05/10 3:06pm

      Matt Taylor says:

      Yes I have tried it on other web hosts, no change.

    • 08/05/10 3:30pm

      Pippin Williamson says:

      I found a solution.

      Apparently assigning an ID to each widget breaks it. Remove


      'id' => 'footerL-widgetarea',


      from each widget and everything should work fine.

  • avatar
    Last edited:
    08/05/10
    2:18pm
    Rashad Aliyev says:

    Hello,

    Change your theme to Default and check it again.

    • 08/05/10 2:20pm

      Matt Taylor says:

      That was the first thing I tried. Even uninstalled the theme.

    • 08/05/10 2:26pm

      Rashad Aliyev says:

      If it's not happened after installing some plugins then it may causing from your hosting settings.

    • 08/05/10 2:39pm

      Rashad Aliyev says:

      Try to change this code with yours please.

      P.S: Don't forget backup your files.

      <?php

      /*** WIDGETS ***/
      // Check if widget area is active source: http://themeshaper.com/registering-new-sidebars-for-custom-page-templates-the-smart-way/
      function is_pagetemplate_active($pagetemplate = '') {
      global $wpdb;
      $sql = "select meta_key from $wpdb->postmeta where meta_key like '_wp_page_template' and meta_value like '" . $pagetemplate . "'";
      $result = $wpdb->query($sql);
      if ($result) { return TRUE; } else { return FALSE; } } // is_pagetemplate_active()
      // Register widgetized areas
      if ( function_exists('register_sidebars') ) {
      register_sidebar(array(
      'name' => 'Sidebar',
      'id' => 'sidebar-widgetarea',
      'description' => __('This is right sidebar & is the primary widget area.', 'sidebar-widgetarea'),
      'before_widget' => '<div id="%1$s" class="%2$s widget sidebar-widget">',
      'after_widget' => "</div>",
      'before_title' => '<h3 class="widget-title sidebar-widget-title">',
      'after_title' => '</h3>' ));

      register_sidebar(array(
      'name' => 'Footer, left',
      'id' => 'footerL-widgetarea',
      'description' => __('Widget area for the footer, left side.', 'footerL-widgetarea'),
      'before_widget' => '<section id="fwal"><div id="%1$s" class="%2$s widget footer-widget fw-left">',
      'after_widget' => '</div></section>',
      'before_title' => '<h3 class="widget-title footer-widget-title fw-left-title">',
      'after_title' => '</h3>' ));

      register_sidebar(array(
      'name' => 'Footer, middle left',
      'id' => 'footerML-widgetarea',
      'description' => __('Widget area for the footer, middle left side.', 'footerML-widgetarea'),
      'before_widget' => '<section id="fwar"><div id="%1$s" class="widget %2$s fw-rightblock">',
      'after_widget' => '</div></section>',
      'before_title' => '<h3 class="widgettitle fw-rightblock-title">',
      'after_title' => '</h3>' ));

      register_sidebar(array(
      'name' => 'Footer, middle right',
      'id' => 'footerMR-widgetarea',
      'description' => __('Widget area for the footer, middle right side.', 'footerMR-widgetarea'),
      'before_widget' => '<section id="fwar"><div id="%1$s" class="widget %2$s fw-rightblock">',
      'after_widget' => '</div></section>',
      'before_title' => '<h3 class="widgettitle fw-rightblock-title">',
      'after_title' => '</h3>' ));

      register_sidebar(array(
      'name' => 'Footer, right',
      'id' => 'footerR-widgetarea',
      'description' => __('Widget area for the footer, right side.', 'footerR-widgetarea'),
      'before_widget' => '<section id="fwar"><div id="%1$s" class="widget %2$s fw-rightblock">',
      'after_widget' => '</div></section>',
      'before_title' => '<h3 class="widgettitle fw-rightblock-title">',
      'after_title' => '</h3>'));


      function emp_template_widgets_init() {
      if(is_pagetemplate_active('page-altsidebar.php') || is_pagetemplate_active('page-altsidebar-noslidertimecomments.php') ||
      is_pagetemplate_active('page-altsidebar-nothingelse.php') ) {
      register_sidebar( array (
      'name' => 'Page Template - Alternate',
      'id' => 'sidebarAlt-widgetarea',
      'description' => __('This is the sidebar for an alternative sidebar page template.', 'sidebarAlt-widgetarea'),
      'before_widget' => '<div id="%1$s" class="%2$s widget sidebarAlt-widget">',
      'after_widget' => "</div>",
      'before_title' => '<h3 class="widget-title sidebarAlt-widget-title">',
      'after_title' => '</h3>' ));
      } // end test for active template

      if(is_pagetemplate_active('page-WPECsidebar.php')) {
      register_sidebar( array (
      'name' => 'Page Template - WPEC',
      'id' => 'sidebarWPEC-widgetarea',
      'description' => __('This is the sidebar for a WPEC page.', 'sidebarWPEC-widgetarea'),
      'before_widget' => '<div id="%1$s" class="%2$s widget sidebarWPEC-widget">',
      'after_widget' => "</div>",
      'before_title' => '<h3 class="widget-title sidebarWPEC-widget-title">',
      'after_title' => '</h3>' ));
      } // end test for active template
      } // test_template_widgets_init()
      add_action ( 'init' , 'emp_template_widgets_init' );

      register_sidebar( array(
      'name' => 'Page Template - 404',
      'id' => '404-widgetarea',
      'description' => __('Widget area for 404 error pages.', '404'),
      'before_widget' => '<div id="%1$s" class="%2$s widget 404-widget">',
      'after_widget' => '</div>',
      'before_title' => '<h3 class="widget-title 404-widget-title">',
      'after_title' => '</h3>'));
      } // end widget areas

      ?>

    • 08/05/10 2:45pm

      Rashad Aliyev says:

      Did you tried my codes? I think it'll work ;)

    • 08/05/10 2:48pm

      Matt Taylor says:

      I'm getting the exact same result my friend. :/

  • avatar
    Last edited:
    08/05/10
    2:25pm
    Eddie Moya says:

    So what you mean is that your in the backend, in the widget editor, and the changes your making are not sticking?

    If thats correct, I need to ask a few more questions...

    What widgets are giving you this problem?

    If they are custom widgets from a plugin then I suggest digging into the plugin's code, not your theme to find the problem.

    If this problem is presenting itself with default widgets... well then I would first test if this is happening with other themes. If it is, then you possibly have some other plugin interfering. If it does NOT happen with other themes, well... then I guess I would have to see the whole theme and run it through step tracing and see what could possibly be stopping changes in the backend from being saved.

    • 08/05/10 2:31pm

      Matt Taylor says:

      This issue happens regardless of which widgets are used. I have tried both custom and WP default to no avail.

    • 08/05/10 2:35pm

      Eddie Moya says:

      Ok, so to sum this up...


      You cant save changes to widgets in the wordpress backend widget editor. The problem happens only on this theme, and even when you deactivate all other plugins?

      I seem to recall a similar problem once upon a time. However mine ended up being a problem with the widget itself, not the theme. If you have isolated this to the point where it can be other other than the theme, I think we need to consider looking at the entire theme and running it.

    • 08/05/10 2:38pm

      Matt Taylor says:

      Is it possible that the array is malformed?

    • 08/05/10 2:47pm

      Eddie Moya says:

      Sure, it can be any of many things. Without being able to run the theme through netbeans and trace the arrays, it would take too long to figure out by guessing. If you can post the theme somewhere for us to download, that would help speed things up.

  • avatar
    Last edited:
    08/06/10
    12:54pm
    wjm says:

    I have been working on design bug in the core wordpress files when registering sidebars, and at first glance, i can say that one line may be causing trouble.

    'id' => 'sidebar-widgetarea',


    sidebar- is a the prefix used for sidebars registered with a missing id, usually used in the form of sidebar-1 for the first sidebar registered, sidebar-2 for the second and so on.

    so my suggestion is change that id to something else cause it may cause conflicts
    i will look at your code later if you cannot solve this issue.
    - wjm

    • 08/05/10 3:35pm

      wjm says:

      also, ALWAYS use an ID when registering a sidebar. because if you move the order, that is you add another sibebar before the onces you have.. ALL YOUR WIDGETS WILL BE GONE.

    • 08/05/10 8:44pm

      wjm says:

      man this is a weird bug,
      i think i tracked it down,
      it has to do with ids having a capital letter.
      so replace

      'id' => 'footerL-widgetarea',

      with
      'id' => 'footerl-widgetarea',

      and it will work

      and whereever you have a capital case in your id.
      more on this later, i will report a bug and patch to trac.wordpress

    • 08/05/10 9:54pm

      wjm says:

      bug and patch submitted,
      http://core.trac.wordpress.org/ticket/14548

    • 08/05/10 10:01pm

      wjm says:

      here is the fixed version of your file,
      i have tested every sidebar and it the widgets remain there after reloading the page.
      http://pastebin.com/km356aEQ

This question has expired.





Current status of this question: Completed