• I’m struggling to understand some confusing behavior with wp_update_post: a direct copy/paste of content completely corrupts a bunch of Gutenberg plugins.

    Example:

    // Get original post
    $my_post = get_post(POST_ID);
    $my_post_content = $my_post->post_content;
    
    // Copy the content and update the post with the same content
    $copy_post = array();
    $copy_post['ID'] =POST_ID;
    $copy_post['post_content'] = $my_post_content;
    wp_update_post($copy_post);
    

    If you do the above on a post that has a PostX Post Grid, for example, the PostX grids on the page will all be corrupted and broken. But I’m not sure why copying and pasting the post content should change anything.

    What am I missing? Thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m unsure what a PostX Post Grid is. I assume it came from a plugin? It may contain references that tie it to a particular post that are invalidated if placed elsewhere? Just idle speculation. For a more definitive answer, I suggest asking through the plugin’s dedicated support channel.

    FWIW, I copied the HTML content for the default query loop block (closest thing I could find to a posts grid) into a different post and it works fine in its new location.

    Thread Starter claren

    (@claren)

    Hey thanks for taking a look.
    Yes, PostX is a popular plugin. I’ve reached out to them about the problem.

    As you suggested, I also just posted in the PostX forum. I wasn’t sure it was a PostX problem, but based on your query test it looks like it is.
    It makes no sense to me since I’m not moving content from one post to another.

    If I learn anything I think could be valuable, I’ll post it here.

    • This reply was modified 2 years, 4 months ago by claren.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_update_post updates more than expected’ is closed to new replies.