-
-
Save phillcoxon/9015279 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.