• janemig

    (@janemig)


    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)
  • Thread Starter janemig

    (@janemig)

    Here is my speakers query statement, in case I need to ‘blend’ anything into it:

    <?php $temp = $wp_query;
    					$speakers = new WP_Query( array(
    						'post_type' => 'speakers',
    						'paged'=>$paged,
    	                     'orderby'=>'title',
    	                     'order'=>'ASC'
                          ) ); ?>	
    
    					<?php if ( $speakers->have_posts() ) : while ( $speakers->have_posts() ) :  $speakers->the_post(); ?>

    Thread Starter janemig

    (@janemig)

    Do I need to create a taxonomy template file, i.e. taxonomy-event-names.php? And if so, what goes in it?

    Thread Starter janemig

    (@janemig)

    Anyone??

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.