[Solved] Understanding WordPress database schema – querying from 3rd party app


You’re looking for all posts where post_status = publish and post_type = post.

The WordPress posts table also includes pages, revisions, and attachments … that’s why you need to be specific.

If you’re using the default database scheme (with wp_ as a table prefix), the following query will give you what you need:

SELECT post_title FROM wp_posts WHERE post_status="publish" AND post_type="post" ORDER BY post_date DESC

This will give you a list of the most recent headlines (post titles) of published posts ordered by date (with the most recent at the top). No need to import any core WordPress libraries. Just make sure not to accidentally tweak the database while accessing it directly or you might break something in WordPress.

1

solved Understanding WordPress database schema – querying from 3rd party app