Skip to content

Instantly share code, notes, and snippets.

@coderaaron
Last active March 13, 2020 02:34
Show Gist options
  • Save coderaaron/79b515fe4b9a6732f3e27b584007c20e to your computer and use it in GitHub Desktop.
Save coderaaron/79b515fe4b9a6732f3e27b584007c20e to your computer and use it in GitHub Desktop.
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