Add Action wp_update_post not Updating WYSWIAG editor

When we use the wp_update_post function, and do a pre_post_update action, it gets updated in the database, but the WYSWIAG editor shows the revision just made, not the processed one.

For example post_content = “test 1 test2”

Save Post Draft post_content as seen in wp-admin WYSWIAG/text = “test 1 test2”

Save Post Draft post_content as seen in database = “test one test2”

Then if you refresh the page, WYSWIAG editor shows = “test one test2” (with the HTML rendered)

Code is as follows:

function regexcheck($post_id){
$post_type = get_post_type();

if ( $post_type == ‘story’ ) {

remove_action(‘pre_post_update’, ‘regexcheck’);
require_once(‘regex.php’);

global $post;
$content = $post->post_content;
$post_id = $post->ID;
$response_array = zenger_regex($content);
$update_post = $response_array[‘finalString’];

$my_post = array(‘ID’=>$post_id, ‘post_content’=> $update_post);
wp_update_post($my_post);

return $response_array;
add_action(‘pre_post_update’, ‘regexcheck’);

}
}
add_action(‘pre_post_update’, ‘regexcheck’);

I tried moving the action to init but that does not solve it. Also tried putting in a sleep, but it did not work. Not sure what I am missing here.

Read more here:: Add Action wp_update_post not Updating WYSWIAG editor

Leave a Reply

Your email address will not be published. Required fields are marked *