Site icon Hip-Hop Website Design and Development

Refresh Gutenberg with JS for it present up to date put up

I up to date the put up content material after the saving. As an instance I’m change apple to banana.

operate apple_to_banana($content material){
    $content material = str_replace('apple', 'banana', $content material);
    return $content material;
}
add_filter('content_save_pre', 'apple_to_banana');

However I’ve downside that after the saving the put up in Gutenberg not up to date and displaying apple turned of banana. Clearly if I’m refresh the web page in browser the up to date put up dispalyed.

I wish to refresh the put up in Gutenbrg. I attempt to run refreshpost with wp.knowledge.dispatch('core/editor').refreshPost(); however Gutenberg not refreshed.

How I can refresh Gutenberg solely and present up to date put up?