Please backup your database before trying
In your current theme, open the functions.php
file and add the code below. In theshortcodeyouhate
inform the shortcode you want to get rid of, note that even extended types works nicely!
Once you added this code, hit F5 and you are done.
add_action ('init','remove_shortcode_from_db'); //you can choose any other actions such wp_head etc
function remove_shortcode_from_db($shortcode="theshortcodeyouhate") {
global $wpdb;
$posts = $wpdb->get_results("SELECT ID,post_title,post_content FROM
$wpdb->posts");
$regex =
'/\[(\[?)('.$shortcode.')\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([
^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/s';
foreach($posts as $post) {
$final = preg_replace($regex,'',$post->post_content);
$change = $wpdb->update( $wpdb->posts, array('post_content' =>
$final), array('ID' => $post->ID));
}
}
Thanks to wp-hackers mailing list