Title: delete posts from database
Last modified: August 19, 2016

---

# delete posts from database

 *  [snking](https://wordpress.org/support/users/snking/)
 * (@snking)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/delete-posts-from-database/)
 * Hello,
 * Because Saturn takes reverse satellites on jupiter and moon is full which is 
   bad for my horoscope… I have Doubled every post in my wordpress, about 2900 articles.
 * I have doubled every post in category named “big category”
 * no article is solo in “big category” but the doublicated articles (bad ones) 
   are solo in “big category”
 * I tried to filter every article from “big category” in order to select them and
   delete them but it is mereley impossible as I see 2900 doubled posts + 900 that
   are the normal ones.
 * so.. is there any sql command that i can execute in order to delete every article
   that is ONLY in “big category”?
 * i tried from phpMyAdmin to check it but i didnt understand very well the structure.
 * of course any other work around or suggestion is very welcome.
 * thank you i n advance.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Snat](https://wordpress.org/support/users/snat/)
 * (@snat)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/delete-posts-from-database/#post-1814183)
 * In PhpMyAdmin, what is the category ID for “big category”. Need it to write a
   SQL statement for you.
 *  [christopherross](https://wordpress.org/support/users/christopherross/)
 * (@christopherross)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/delete-posts-from-database/#post-1814187)
 * Here’s a fast and dirty fix for you.
 * If you change ‘6’ to the category you want to delete all posts from, this will
   list all posts in that category for you. I’m purposely breaking this into two
   code samples so you can test this first.
 * Insert this code into your header.php and load a page, it should list the posts
   you want to delete:
 *     ```
       $args=array('cat' => '6')
       $feature_post = get_posts($args);
   
       foreach( $feature_post as $post ) : setup_postdata( $post );
   
       echo "<br>".get_the_title();
   
       endforeach;
       ```
   
 * If that listed ONLY the ones you want to delete,
 * then replace `echo "<br>".get_the_title();` with `wp_delete_post();` and it will
   delete the post instead of displaying it.
 * Most likely, your server will time out while performing the task, so you could
   always run:
 *     ```
       $args=array( 'numberposts'=> 50,'cat' => '6')
       $feature_post = get_posts($args);
   
       foreach( $feature_post as $post ) : setup_postdata( $post );
   
       echo "<br>".get_the_title();
       //wp_delete_post();
   
       endforeach;
       ```
   
 * This would run in groups of 50 to cut down on server timeouts.
 * NOTE: I’ve commented the wp_delete_post(); on purpose. To make it work, remove
   the //

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘delete posts from database’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [christopherross](https://wordpress.org/support/users/christopherross/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/delete-posts-from-database/#post-1814187)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
