Skip to content

Instantly share code, notes, and snippets.

@twentyfortysix
Last active February 13, 2016 19:51
Show Gist options
  • Save twentyfortysix/5658753 to your computer and use it in GitHub Desktop.
Save twentyfortysix/5658753 to your computer and use it in GitHub Desktop.
WP - content cleaner
// cleaner
// credits http://wordpress.stackexchange.com/questions/52097/better-way-to-remove-html-syntax-from-all-content
$tochange = get_posts('post_type=product&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>'); // post_excerpt
print_r($post->ID);
echo '<br />';
$out = wp_update_post($changed);
echo 'changed:'.$out.'<br />';
unset($changed);
endforeach;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment