Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save loorlab/1598f19af87a8433430be65dec8afa23 to your computer and use it in GitHub Desktop.
Save loorlab/1598f19af87a8433430be65dec8afa23 to your computer and use it in GitHub Desktop.
Query - MySQL - WordPress | Display all Posts exclude pages and other content type
SELECT
p.ID,
p.post_title,
p.post_status,
CONCAT(u.option_value, '/', p.post_name, '/') AS permalink
FROM
wp_posts p
JOIN
wp_options u
ON u.option_name = 'siteurl'
WHERE
p.post_type = 'post'
AND p.post_status IN ('publish', 'draft', 'pending', 'private')
ORDER BY
p.post_date DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment