Just a collection of SQL queries I find useful in WordPress management
Last active
December 13, 2018 04:16
-
-
Save dgowrie/ebde7a89fd3d42bc1837818a0c6b78fd to your computer and use it in GitHub Desktop.
SQL queries for WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT P.ID, P.post_title, M.meta_key, M.meta_value | |
| FROM wp_posts AS P | |
| JOIN wp_postmeta AS M ON P.ID = M.post_id | |
| AND M.meta_key = 'CUSTOM_FIELD' | |
| WHERE P.post_type = 'products' | |
| order by P.ID asc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT P.ID, P.post_title, M.meta_key, M.meta_value | |
| FROM wp_posts AS P | |
| INNER JOIN wp_postmeta AS M ON M.post_id = P.ID | |
| WHERE P.post_type = 'page' and P.post_status = 'publish' and M.meta_value = 'TEMPLATE_PATH/FILENAME.php' | |
| ORDER BY post_title, meta_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT P.ID, P.post_title | |
| FROM wp_posts AS P | |
| WHERE P.post_type = 'products' and P.post_status = 'publish' | |
| ORDER BY post_title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment