MySQL Query to List WordPress Posts Using Meta Query
To get a list of WordPress Posts using meta query in MySQL, you can use the following SQL query:
SELECT p.ID, p.post_title, m.meta_id, m.meta_key, m.meta_value FROM `wp_posts` p LEFT JOIN `wp_postmeta` m ON p.ID = m.post_id WHERE m.meta_key = 'wpcf-show-status' AND m.meta_value <> '' ORDER BY p.post_title ASC
This query will create a list with ID, post title, meta key and meta value that fits to this WHERE clause. You need to update meta_key
and meta_value
values before running on your database. Otherwise you will get an empty result set.