WordPress.org

Ready to get started?Download WordPress

Forums

Flexible Posts Widget
[resolved] Query to update template (2 posts)

  1. winstonion
    Member
    Posted 1 year ago #

    Hi - thanks for you plugin, so far I have found it very useful.
    Question:
    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?
    Thanks

    http://wordpress.org/extend/plugins/flexible-posts-widget/

  2. DaveE
    Member
    Plugin Author

    Posted 1 year ago #

    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:
    http://nacin.com/2010/04/18/wordpress-serializing-data/

    And here's a tool/PHP script that you can use to update serialized data in the DB:
    http://interconnectit.com/124/search-and-replace-for-wordpress-databases/

    Hopefully that helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic