WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I changed theme/plugin now the post content still display shortcodes.

There are some tips around on hiding them, but everytime I use some content functions, the shortcodes shows up again. Also, my shortcodes are the "extended type" such [theshortcode id="34877"], [theshort size="large" "tiny"] etc so the tips on removing them from database doesn't work at all.

share|improve this question
up vote 1 down vote accepted

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
$regex =

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

share|improve this answer
Hi Diana, it sounds like you solved the problem, so you should mark this as the accepted answer. – Ian Dunn Jul 18 '12 at 6:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.