How get the Pods for one taxonomy term, but without another term
-
Hi,
Getting more and more out of pods. 🙂
Now I need to show the Pods that are linked to a pod-term, but does not have another term.The where is giving no errors, but due to the complex join structure, it does not exclude the second term.
In query-monitor the query is:SELECT DISTINCT
t
.*
FROMwp_posts
ASt
LEFT JOINwp_podsrel
ASrel_exercise
ONrel_exercise
.field_id
= 84
ANDrel_exercise
.item_id
=t
.ID
LEFT JOINwp_posts
ASexercise
ONexercise
.ID
=rel_exercise
.related_item_id
LEFT JOINwp_term_relationships
ASrel_ewtag
ONrel_ewtag
.object_id
=t
.ID
LEFT JOINwp_term_taxonomy
ASrel_tt_ewtag
ONrel_tt_ewtag
.taxonomy
= 'ewtag'
ANDrel_tt_ewtag
.term_taxonomy_id
=rel_ewtag
.term_taxonomy_id
LEFT JOINwp_terms
ASewtag
ONewtag
.term_id
=rel_tt_ewtag
.term_id
WHERE ( (exercise
.ID
=2059 andewtag
.term_id
=31 andewtag
.term_id
!=32 )
AND (t
.post_type
= 'exerciseword' )
AND (t
.post_status
IN ( 'publish' ) ) )
ORDER BYt
.menu_order
,t
.post_title
,t
.post_date
The where part for the terms is:
ewtag
.term_id
=31 andewtag
.term_id
!=32. First I used the slug, but I hoped using the id, would reduce the joins.
I need the pagination, else I could do a foreach on the results.
I hope someone can help me out here.
Thanks in advance, flexjoly
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.