Skip to content

Instantly share code, notes, and snippets.

@dgowrie
Created June 19, 2019 03:03
Show Gist options
  • Save dgowrie/8e6a025c09a2a5676c457285d32731b5 to your computer and use it in GitHub Desktop.
Save dgowrie/8e6a025c09a2a5676c457285d32731b5 to your computer and use it in GitHub Desktop.
SQL query for posts using specific page template in WordPress
SELECT post_title, ID, post_status, post_name
FROM wp_posts p
LEFT JOIN wp_postmeta m
ON p.ID = m.post_id
WHERE (m.meta_key = '_wp_page_template' AND m.meta_value = 'default')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment