Is there a way to get rendered html content of a WP post after updating?

I tried adding a filter at the content etc but that one just gives access to content stored in wp_posts. I am interested in getting the rendered html with meta tags etc for a post, after it is updated. How can I do this?

I can do, but it does not look like the best option to me as the blog might have a paywall and this code would fail. What else is available?

add_action( 'save_post', 'my_save_post_function', 10, 3 );

function my_save_post_function( $post_ID, $post, $update) {
    $url = $post-guid;
    $richSnippets = file_get_contents($url);
    // do what you need to do with html
}

I thought of using the link of preview instead of post url - but I don't know if preview link would also fail to retrieve the whole content if there is a paywall.

add_action( 'save_post', 'my_save_post_function', 10, 3 );

function my_save_post_function( $post_ID, $post, $update) {
    $preview_url = get_preview_post_link($post);
    $richSnippets = file_get_contents($preview_url);
    // do what you need to do with html
}

Maybe there is a way to invoke the theme and render the page?

Topic post-content the-content save-post plugin-development posts Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.