Imagos Consulting Weblog

Developers Cant Do Design (or Can They?) – Neville Richards Personal Blog

Recovering WordPress Posts

on September 23, 2014

If you ever have to retrieve WordPress posts from a MySQL database the following query may be handy:

SELECT wp_posts.post_title as Title, wp_posts.post_date as DATE,
GROUP_CONCAT( AS TAGS, wp_posts.post_content as CONTENT FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id
INNER JOIN wp_term_relationships ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
INNER JOIN wp_posts ON wp_posts.ID = wp_term_relationships.object_id
WHERE post_type LIKE 'post' AND post_status LIKE 'publish' GROUP BY wp_posts.ID order by post_date

I would recommend the WordPress interface layer for general application access to a WordPress database.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: