Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
(
    SELECT * 
    FROM $wpdb->posts
    INNER JOIN 
        wp_term_relationships ON $wpdb->posts.ID = wp_term_relationships.object_id
    WHERE 
        wp_term_relationships.term_taxonomy_id = 7
        AND
        $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 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 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 at 10:30
    
found it, thanks! –  Fabriziov Jul 17 at 14:08

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.