• Hey

    i want to replace a word in the main Content of an Site. But because of the Sitebuilder Plugin the Content is Stored in many Arrays in the Post_meta “panels_data”. So i tried to replace the Words in the SQL rather than in the Arrays.

    I tried the following but nothing happened an i dont get an error message:
    The Variable $new_post_id is the ID from the Post i want to change.

    $query = “UPDATE wp_postmeta WHERE post_id = “.$new_post_id.” SET panels_data = REPLACE (panels_data,’NAME1′,’NAME2′)”;
    $wpdb->query($query);

Viewing 1 replies (of 1 total)
  • Are you certain that this plugin saves its data in the post meta table? I would suggest you make sure of that first. Search also inside the posts and options table so that, first of all, you will know for sure where these data are.

    However, in any case, even when you find what you are looking for, if the data are stored in PHP arrays, then replaceing them like you say will probably break them. This is because PHP objects have a special formality, which is handled by PHP, and keep track of string lengths, etc. So if you manually change ie a string inside them they might break.

    The correct way to do this is to write a bit of PHP code that iterates over the database rows you need, or, even better, over the objects (be it posts, options or post meta) that you need to change and then edit and re-save them via PHP.

Viewing 1 replies (of 1 total)

The topic ‘Replace something in Post_meta SQL Table’ is closed to new replies.