Support » Fixing WordPress » Delete all posts for a category

  • Is it possible to delete all posts from a particular category? I’m new to WP, and have moved over from MT and successfully imported all of my old site, however some of the posts were specific to my MT setup and now need to go (over 300 of them so don’t want to do it by hand!).

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not through WordPress, but you can do this with a DELETE command in MySQL.

    [WARNING: Back up your database before doing something as destructive as this]

    DELETE FROM wp_posts, wp_post2cat USING wp_posts, wp_post2cat WHERE wp_posts.ID=wp_post2cat.post_id AND wp_post2cat.category_id="CAT#";

    Replace CAT# with the numeric ID of the category. This removes the posts from the posts table, as well as the references to them under post2cat (the table that assigns categories to posts). If you are using a different table prefix than wp_, make sure to correct this in the query line above.

    How about including the comments in that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delete all posts for a category’ is closed to new replies.