Skip to content

Instantly share code, notes, and snippets.

@steroyle
Last active June 30, 2022 15:27
Show Gist options
  • Save steroyle/7c436d2c03172490eed1a9d50588215f to your computer and use it in GitHub Desktop.
Save steroyle/7c436d2c03172490eed1a9d50588215f to your computer and use it in GitHub Desktop.
Get a list of WordPress post using a page template and the name of the template.
SELECT
wp_postmeta.post_id,
wp_postmeta.meta_value,
wp_posts.post_title,
wp_posts.post_name
FROM
wp_postmeta
INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID
WHERE
meta_key = "_wp_page_template"
ORDER BY
meta_value ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment