I am making a custom WP_Query and I need to come up with a SQL query that gets the posts IDs from X categories and Y authors. Then merge those IDs and put them in an array.

I only need to figure out the SQL query. Everything else, I got it.

I have looked everywhere for this but no one has been able to help me. Please help me out!!

| improve this question | | | | |

Not the best solution :P but this could help you:

    wp_posts p,
    wp_term_relationships r,
    wp_term_taxonomy tt,
    wp_terms t
    p.post_author in (1, 2, 3)
        and r.object_id = p.ID
        and tt.term_taxonomy_id = r.term_taxonomy_id
        and tt.taxonomy = 'category'
        and tt.term_id = t.term_id
        and t.term_id in (1, 2, 3);
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.