JOIN query for retrieving the last post from specific categories
-
Hello to everyone!
I have the following code for WordPress:
SELECT terms.*, posts.ID as post_ID FROM wp_terms terms JOIN wp_term_taxonomy term_taxonomy ON terms.term_id = term_taxonomy.term_id JOIN wp_term_relationships term_relationships ON ( term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id AND term_taxonomy.taxonomy = 'category' ) JOIN wp_posts posts ON ( posts.ID = term_relationships.object_id AND posts.post_type='post' AND posts.post_status='publish') WHERE terms.term_id=19 OR terms.term_id=20 OR terms.term_id=21 OR terms.term_id=22 GROUP BY terms.term_id ORDER BY posts.post_modified_gmt DESC
I want to retrieve the last post from specific categories. But it returns the first post of each category. What am I doing wrong?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘JOIN query for retrieving the last post from specific categories’ is closed to new replies.