View Single Post
Old 03-25-2012, 02:24 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 54,508
if you want to remove it completely from the db, here is the code i use/used

Code:
function remove_shortcode_from_db($shortcode = 'button') {

    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));
    }
}
Code:
remove_shortcode_from_db('downloads_box');
always backup your database before doing any mods like this.
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


my contact: fris at fris.net

Last edited by fris; 03-25-2012 at 02:25 PM.. Reason: ps, only run once.
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote