0

Ciao guys, I am trying to get products by an $wpdb->get_col() SQL query, but I am in trouble with the SQL syntax. I need products which have an exact category and IN at least one taxonomy terms.

SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (142,77,76,84,83) AND term_taxonomy_id = 135

This SQL doesn't work, but I hope there is a solution to run such a query. Thanks,

  • is there a reason you're using raw SQL and not WP_Query with a tax_query parameter? – Tom J Nowell Jul 9 at 13:50

Your Answer

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

Browse other questions tagged or ask your own question.