SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot kiviniar's Avatar
    Join Date
    Aug 2006
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Bulk delete WP post via mysql query

    I want to delete posts that I have made in a particular category in WP [more than 2000+]

    How can I delete all the post from a particular cateogy[Uncategorized] via a MYSql query.

    What query do I need to run?

    Thanks for looking.

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The post category is listed as a numerical system. Browse your database for a post you know is of the category you wish to delete all of, and form the query as so.

    Code SQL:
    DELETE FROM wp_posts WHERE post_category = 'x'

    So, with x being your post category of course you can delete all of a certain category. However, make sure that you did not delete that category name first, because this then makes them all uncategorized, and you will be taking all of those out as well. Cheers :-)

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    if post_category is numeric, then you would not want to put quotes around the number -- you're just forcing a datatype conversion from string to number which is needless extra work
    Code:
    ... WHERE post_category = N
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah yes. Sorry :-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •