Support » Plugin: Flexible Posts Widget » [Plugin: Flexible Posts Widget] Query to update template

  • Resolved winstonion


    Hi – thanks for you plugin, so far I have found it very useful.
    I built an alternate template according to your instructions, and it works, but I wanted to update about 25 Flexible Post Widgets to use this new template. I figured I could do this with an update query but it didn’t seem to work.
    My query:
    UPDATE wp_options SET option_value = REPLACE(option_value,'widget.php','my_custom.php') WHERE option_id = 1286 and option_name = 'widget_dpe_fp_widget'

    It looks like the query updated the option_value string correctly but reloading the widgets page showed that all my sidebar widgets dropped off. I didn’t think there would be any problem doing this if I only touched that one portion of the string.

    Any ideas?

Viewing 1 replies (of 1 total)
  • Plugin Author DaveE


    Hi Winstonion,

    WordPress stores widget options (and many other values) in the database as serialized strings. In order to update those values correctly, you’d need to unserialize the string, update it and then re-serialize it before replacing the value in the DB.

    When the serialized data gets corrupted (by performing a MySQL update directly on the serialized data) the widget or other item using that data is essentially ignored by WordPress. Hence, you widgets have disappeared.

    To recover the widgets that have been lost, you may be able to just re-update the DB value back to the initial ‘widget.php’. This may or may not work depending on how corrupted the data became. You could also revert to a backup of the DB or specific DB table if you have that.

    Here’s a bit of an explanation from Nacin regarding WP’s serialized strings:

    And here’s a tool/PHP script that you can use to update serialized data in the DB:

    Hopefully that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Flexible Posts Widget] Query to update template’ is closed to new replies.