The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] 2.8-bleeding-edge Sidebars and Multi-Widgets (3 posts)

  1. ty
    Posted 7 years ago #

    I've got a variable number of dynamic sidebars in my custom theme with 13 minimum. The problem I'm having right now is that whatever sidebar happens to be the 3rd one registered, does not show the first instance of some of the widgets placed inside of it (like the recent posts and some of my custom widgets). I haven't tested this extensively to know all the affected widgets/sidebars, but sidebar #3 and the default recent posts widget are causing problems. The strange thing is that if I put 2 instances of the recent posts widget, the 2nd will show up no problem (and the same with my other custom widgets). I'm pretty sure this error isn't being caused by any of my code, since all my sidebars are the same and this problem doesn't occur with any of the other sidebars I've tested (again, I didn't test all of them). This behavior seems completely unrelated to any of the widgets in other sidebars. Any ideas? I don't have the time right now to peruse the widgets.php include or I would try and narrow it down more (maybe later tonight).

  2. ty
    Posted 7 years ago #

    Nevermind!!! I just figured out that the problem was with the use of ob_get_flush(); in the recent posts widget, and the custom widgets that I modeled after it. I changed them around to follow the format of the default recent comments widget and it seems to have fixed the problem. I'll leave this up in case anyone else has any trouble, and recommend that the default recent posts widget be changed to accomodate those of us that wrap the sidebar output in an output buffer).


  3. ty
    Posted 7 years ago #

    It seems my previous assessment was a tad hasty! Upon further inspection I decided to rework the caching of my widgets, and discovered that ob_get_flush() was actually not to blame. The problem lies in the returning of the cached widget contents.

    The problem is with the code that reads something like the following:

    if (isset($cache[$args['widget_id']]))
       return $cache[$args['widget_id']];

    I fixed it by changing it to the following:

    if (isset($cache[$args['widget_id']]))
       echo substr($cache[$args['widget_id']][1], 1);

    As otherwise the widget contents get echoed twice. I can only assume that this is a bug with the current wp_caching methods?

    Any of the main devs want to look into this???

Topic Closed

This topic has been closed to new replies.

About this Topic