Wordpress widgets are disappearing in admin area
Asked Answered
C

7

7

My company is being paid to optimize a Wordpress site, I am trying to make some modifications that should be showing up in the widgets section (forms, testimonials etc).

With their custom theme, in the widgets section, on the right hand side where it lists all the sidebars, if I expand any, they are empty. If I drag a text widget over and add "Test", and then Save, it will show up on the front end, but once the widgets page refreshes, if I expand the sidebar again, it shows empty. The widgets show up under inactive widgets but not to the right where I should be able to edit them.

I have tried this using the default theme and the widgets show up as expected. I don't know enough about Wordpress to know where to look to fix the widgets disappearing from the admin sidebar section.

Cene answered 9/5, 2011 at 18:21 Comment(1)
i was JUST writing out my problem when i saw this so bump!...i still cant figure it out...ive been tasked in an emergency to redo this badly coded site and now i run into this....hard to edit what i cant see in the sidebar area.Squirearchy
S
15

this is the solution.

we just need to change the id of sidebar. id should be only in small letters. Caps are not allowed. if we use cap id in any of the sidebar, the problem occurs in the same sidebar or any other sidebar of automatically removing widgets on refresh.

I am just mentioning an example below.

This is the Wrong Pattern -

register_sidebar( array(
        'name' => __( 'Main Sidebar', ),
        'id' => 'Sidebar-1',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

This is the right pattern. Note i just changed the id to correctly configure the widgets saving.

register_sidebar( array(
        'name' => __( 'Main Sidebar', ),
        'id' => 'sidebar-1',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => "</aside>",
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

Secondaly, wordpress has not mentioned anywhere, that id should be in small letters, this is another bug by wordpress. But in such big cms, these things are bound to happen.

Supportable answered 10/8, 2012 at 6:2 Comment(4)
I'm having this same exact problem, but im not using any cap letters in the id's....Nomology
Thank you =D u saved my day and night this bug was killing meSmaze
I had the same problem, but my ids were all numbers. So when I set '10' to 'sidebar-10' and '20' to 'sidebar-20' and so on everything worked again.Astraea
I faced similar problem, I have a _s theme and wanted to develop on top a plugin with widgets. In the functions.php theme we have add_action ('widget_init', some_func); in order to register theme's sidebars. My custom plugin wants to register a widget using add_action('widget_init', 'some_func'); the solution is to pass high priority greater than 10 defaults to my custome widget such as add_action('widget_init', 'some_func', 1000); this solved my problem :)Trombone
U
2

I got the same issue after I changed the sidebars ids (in register_sidebar)

The sidebars show in admin part, I can change their content, which is reflected in front end, but refreshing admin page displays empty sidebars (and saving reflects empty sidebars in front end)

I could solve it by removing the sidebars (remove the calls to register_sidebar), updating admin page, which suddenly showed all the widgets in inactive widgets list (a lot of them since I put new widgets many times before solving the issue), and re-activating the calls to register_sidebar.

Uphemia answered 26/10, 2011 at 15:8 Comment(0)
S
2

I had the same issue and solved it by modifying the name of the widget to lower case as per the best solution here. i experienced this issue on 3.6

Syllabary answered 2/12, 2013 at 19:23 Comment(0)
P
1

I had the same problem. I had the wrong quotation mark. Try to change from >"< into >'<

FROM:

   'id'=> "sidebar-1",

TO:

'id'=> 'sidebar-1',
Photokinesis answered 17/7, 2014 at 12:12 Comment(0)
I
0

I've had the same issue and have dealt with it a couple of days, it all came from the ids - I changes them to no caps and no spaces and it magically worked ! Finally! Good luck!

Intima answered 6/4, 2015 at 14:7 Comment(0)
S
0

I had the same problem and solved uninstalling the plugin Google Analyticator. Check if you have that plugin installed or another one of google analytics.

Shipwreck answered 3/6, 2018 at 8:21 Comment(0)
B
0

I had a similar problem but mine was due to the id being a number. I had selected 404 and the widgets disappeared on refresh. I renamed the id to fourohfour and it resolved the problem.

Breast answered 7/9, 2018 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.