Complex mySQL query to delete posts and update tag count (2 posts)

  1. jeff_ngan
    Posted 7 years ago #

    Hello, I'm trying to bulk delete a bunch of posts, and I'd like to use a mySQL query to do this instead of the bulk delete option built into WordPress (don't ask). The problem is that if I run a query to delete a row in the wp_posts table, it doesn't update the corresponding values in the other tables. This means my count for a particular tag doesn't decrement either, and my tag cloud remains unaffected by the deletion.

    So I'm looking for a query I can run that will not only delete the latest post, but will also update the other table(s) correspondingly to change the count for the number of entries with a particular tag. I don't need anything else updated (like comments or categories, because I have none), only the tag count.

    Any mySQL gurus out there that can help me with this complex query? If so, I will give you a virtual high-five.

  2. jeff_ngan
    Posted 7 years ago #

    After some more digging around, I found the wp_delete_post() function. This would also work, but I'm not sure how to call the function to delete only the most recent post.

Topic Closed

This topic has been closed to new replies.

About this Topic