Last active
February 17, 2017 23:01
-
-
Save salase/e093c817e867170d510679fb06ede38c to your computer and use it in GitHub Desktop.
This file contains 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, p.post_name, p.post_parent, | |
(select pp.post_name from wp_posts pp where pp.id = p.post_parent) as parent_name | |
FROM `wp_posts` p | |
join `wp_term_relationships` tr on p.id=tr.object_id and p.post_type='post' | |
join `wp_term_taxonomy` tt on tr.term_taxonomy_id=tt.term_taxonomy_id and tt.taxonomy='category' and tt.term_id = <ID> | |
order by p.post_parent, p.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment