WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i need a list of the latest post published by various authors, but filtered by category, like for example the latest posts of author that write about music.

i wrote this query and looks like working in mysql

    SELECT * 
    FROM $wpdb->posts
        wp_term_relationships ON $wpdb->posts.ID = wp_term_relationships.object_id
        wp_term_relationships.term_taxonomy_id = 7
        $wpdb->posts.post_status = 'publish'

    ORDER BY $wpdb->posts.post_date DESC
AS x GROUP BY post_author

(the 7 is just an example category id)

i just would like to know the other $wpdb functions to call the wp_term_relationships table and if is there something wrong with this query

thank you in advance

share|improve this question
What's wrong with plain old WP_Query? – deflime Jul 17 '14 at 8:42
that i need just the last post written by each author and filtered by a category, like i need the last post by each author writing about music – Fabriziov Jul 17 '14 at 8:45
You can get a reference to the wp_term_relationship with $wpdb->term_relationships. More core.trac.wordpress.org/browser/trunk/src/wp-includes/… – Laxmana Jul 17 '14 at 10:30
found it, thanks! – Fabriziov Jul 17 '14 at 14:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.