Hi,
I need to display some posts using a custom select query. This custom select query needs to get the posts in two taxonomies.
Look the query:
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID =
$wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy
ON($wpdb->term_relationships.term_taxonomy_id =
$wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id =
$wpdb->terms.term_id)
WHERE
$wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = 'continentes'
AND $wpdb->terms.slug = 'asia'
AND $wpdb->term_taxonomy.taxonomy = 'pais'
AND $wpdb->terms.slug = 'china'
ORDER BY $wpdb->posts.post_date DESC
If a just use one condition the query works well, like it:
... AND $wpdb->term_taxonomy.taxonomy = 'continentes' AND $wpdb->terms.slug = 'asia' ...
But I need the posts in taxonomy "continentes" and "pais".
Best regards