Skip to content

Instantly share code, notes, and snippets.

@phillcoxon
Forked from nciske/clean_post_content.php
Created February 15, 2014 06:21
Show Gist options
  • Save phillcoxon/9015279 to your computer and use it in GitHub Desktop.
Save phillcoxon/9015279 to your computer and use it in GitHub Desktop.
<?php
// Warning: this will overwrite every post in your database
// BACKUP FIRST!
clean_post_content();
function clean_post_content() {
$posts = get_posts(array(
'post_type' => array('post'), // or page, or cpt
'post_status' => 'publish', // or any, draft, etc
'numberposts' => -1, // all posts or number of posts to process
));
foreach ($posts as $p) {
$p->post_content = wp_filter_kses($p->post_content);
wp_update_post($p);
echo 'Cleaned post # '.$p->ID.'<br>';
}
die();
}
@phillcoxon
Copy link
Author

Add this script into a page template, apply that template to a new page, save, visit that page, and it will scan through all your posts and apply the format eraser (that eraser button in the editor) to all your posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment