0

Hello all i need remove all info in Wordpress posts content and i'ld like do it from phpmyadmin with a query.

I need remove only the text and images from all posts content but not the entire post, so i need know the sql query for do it, please someone can help me? Stew

1 Answer 1

0
  1. Backup your db
  2. Remeber to backup your db
  3. Import the backup in another database, change wp-config.php to use this new database and see if everithing is ok. (Importing is successfull? Site appear without any change?)
  4. Wordpress uses a prefix for table names. The default is 'wp_' but clever guys change it with something else. (The change is made in wp-config.php before install WP). So in my query I will use 'wp_' as table prefix, replace it with your table prefix if it's different.
  5. In the new db (the one created from backup) run this query (remember to change wp_posts if your tables has a different prefix):

    UPDATE wp_posts SET post_content = "", post_excerpt = "" WHERE post_type = 'post' AND post_status <> 'inherit' AND post_status <> 'trash';
    
  6. Check your site and if anything goes wrong change wp-config.php to use the original db and then investigate the problem.

2
  • seem your query move all post in trash? are you sure it's correct
    – Stew
    Commented Aug 23, 2013 at 13:31
  • In trash? absolutely not. It doesn't truncate post in trash and revision posts. If you want truncate even them, use only UPDATE wp_posts SET post_content = "", post_excerpt = "" WHERE post_type = 'post' @Stew
    – gmazzap
    Commented Aug 23, 2013 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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