Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert content with shortcodes to rendered HTML and update post
<?php
define( 'PPI_FOR_EXPORT', 1 );
$a = get_pages();
foreach( $a as $b ) {
$f = $b->ID;
$c = get_post_field( 'post_content', $f );
remove_filter('the_content', 'wpautop');
$d = apply_filters( 'the_content', $c );
$my_post = array(
'ID' => $f,
'post_content' => $d,
);
$e = wp_update_post( $my_post );
if ( $e == 0 ) {
echo "<strong>Error updating post $f<br><strong>";
} else {
echo "Successfully updated post $f<br>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment