Category Archives: Wordpress

MYSQL: A Query to Display WordPress Posts

The following MYSQL query will display your WordPress post data including post metadata.   Just change the filters as required … demonstrated filters include only posts with a status of Publish and a post date less than Now.  Remember to remove the filter on post date if you are searching for Draft posts only.

SELECT posts.*, postmeta.*
    FROM wp_posts posts, wp_postmeta postmeta
    WHERE posts.ID = postmeta.post_id
    AND posts.post_status = ‘publish’
    AND posts.post_date < NOW()
    ORDER BY posts.post_date DESC
IMG_20140713_164442