WordPress SQL Select modification for getting posts by user
-
Hi,
I would like to get the WordPress SQL statement to select the 10 most recent approved posts by user.
I have this statement which selects all the recent posts, but will duplicate users if they posted more than 1.
SELECT p.post_title, p.post_author, p.post_date, p.post_name, wpr.object_id, wp_1_terms.name, wp_1_terms.slug FROM wp_1_terms INNER JOIN wp_1_term_taxonomy ON wp_1_terms.term_id = wp_1_term_taxonomy.term_id INNER JOIN wp_1_term_relationships wpr ON wpr.term_taxonomy_id = wp_1_term_taxonomy.term_taxonomy_id INNER JOIN wp_1_posts p ON p.ID = wpr.object_id WHERE taxonomy = 'category' AND p.post_type = 'post' ORDER BY post_date DESC LIMIT 10
- The topic ‘WordPress SQL Select modification for getting posts by user’ is closed to new replies.