How to query a speaker based on a conditional taxonomy query
-
Hello all,
I’d love some guidance.
I created 2 custom post types: ‘speakers’ and ‘events’. On my Events page is a nested loop of speakers using new WP_query. Works great! Except that for each Event I want to list a different group of speakers. It now shows ALL the speakers on each event page.
So I attached a custom taxonomy called ‘event-names’ with the terms ‘cooking’, ‘organizing’ and ‘budgeting’ to both speakers and events. I attached the appropriate term to each speaker and event. I cobbled together the code below, but not sure it this is correct, and if it is where I should put it. Any help will be greatly appreciated!
// speakers attached to the event-name 'cooking' if ( has_term( 'cooking', 'event-names' ) ) { // speakers attached to the event-name 'organizing' } elseif ( has_term( 'organizing', 'event-names' ) ) { // speakers attached to the event-name 'budgeting' } elseif ( has_term( 'budgeting', 'event-names' ) ) { // event name not specified } else { //not sure what to do here or where to place this code in relation to the above speaker query }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to query a speaker based on a conditional taxonomy query’ is closed to new replies.