SQL query for WordPress Posts

I have been trying to write a SQL select query for getting the all the posts made in wordpress blog (to create a latest news banner). This seem easy enough, doesn’t it. The problems arose due to the post revising done by the wordpress blog application, this was just added a layer of confusion. The wordpress blog database stores multiple records for a single post, one record each saved version of the post. However removing this layer, I found that a simple select query will do the job nicely, and here it is:

SELECT * FROM 'wp_posts' WHERE post_status='publish' order by post_date DESC

Nice and Simple :)

Bookmark and Share

One Response to “SQL query for WordPress Posts”

  1. UGG Boots said:

    Feb 09, 10 at 4:17 pm

    I absolutely enjoyed reading your blog and turn up it both illuminating and interesting. I wish for be sure to bookmark it and plague it as again as I can.

    Thanks
    Bernice Franklin


Leave a Reply