I have a bunch of articles imported via a very old Joomla 1.0 installation. The content of these posts have a lot of unwanted inline html. I was able to clean all with something like this (I made a template with this inside, then I opened it):
<?php $tochange = get_posts('post_type=post&numberposts=-1'); foreach ($tochange as $post): setup_postdata($post); $changed = array(); $changed['ID'] = $post->ID; $changed['post_content'] = strip_tags($post->post_content, '<img><a>'); print_r($post->ID); echo '<br />'; $out = wp_update_post($changed); echo 'changed:'.$out.'<br />'; unset($changed); endforeach; ?>
But it seems a little bloated, considering that makes a loop for every post. Any suggestions?