Support

Account

Home Forums Front-end Issues Nesting relationship querys Reply To: Nesting relationship querys

  • Hi Elliot thank you for the reply. im not with the project yet but i just rewrote some of it. would this work do you think?

    <?php
    /** Template Name: Events Page **/
    ?>
    <?php Utilities::get_template_parts( array( 'parts/shared/html-header', 'parts/shared/header' ) ); ?>
    <div class="wrapper">
     
     
     
    <?php query_posts(array( 'post_type' => 'events','meta_key' => 'date','orderby' => 'meta_value_num','order' => 'DESC' ) );?>
                           
                            <?php while (have_posts()) : the_post();?>
                            <?php $date = DateTime::createFromFormat('Ymd', get_field('date'));?>
                            <?php $currentdate = new DateTime();?>
                            <?php if ($date > $currentdate) { ?>
                            <div class="event-wrapper">
                                    <h1>Upcoming Event : <?php the_title();?></h1>
                                    <div class="row event-wrap">
                                            <div class="span_4 event-info">
                                                    <h2>Event information</h2>
                                                   
                                                   
                                                   
                                                    <img />" />
                                                    <p><?php echo $date->format('l jS F Y'); ?> , <?php the_field('time');?></p>
                                                    <p><?php the_field('event_location_');?></p>                   
                                                    <button class="buttons">Become a speaker</button>
                                                    <button class="buttons">Book Tickets</button>
                                            </div>
                                           
                                            <div class="span_8 event-speakers">
                                                    <h2>Speakers</h2>
                                                   
                                                    <div class="row">
                                                            <?php
                                                            $speakers = get_field('speakers');
                                                            if( $speakers ): ?>
                                                            <?php foreach( $speakers as $speaker): ?>
                                                            <div class="span_6 speaker">
                                                                    <div class="span_5">
                                                                            <img />" />
                                                                           
                                                                    </div>
                                                                   
                                                                    <div class="span_7">
                                                                            <h3><?php the_title();?></h3>
                                                                           
                                                                           <?php
    																			$args = array(
    																			  'post_type' => 'videos',
    																			  'meta_query' => array(
    																				'relation' => 'AND',
    																				array(
    																				 'key' => 'speaker',
    																				 'value' => get_the_ID()
    																				),
    																				array(
    																				 'key' => 'events',
    																				 'value' => $eventid
    																				)
    																			  )
    																			);
    
    																			$videos = new WP_Query($args);
    
    																			if($videos->have_posts()) : 
    																			   while($videos->have_posts()) : 
    																				  $videos->the_post();
    
    																			?>
    
    																			<!-- STUFF FOR EACH VIDEO HERE -->
    																			<?php the_field('youtube_videos');?>
    
    																			<?php
    
    																			endwhile;
    																			endif;
    
    																			?>
                                                                    </div>
                                                            </div>
                                                           
                                                            <?php endforeach; ?>
                                                            <?php wp_reset_postdata(); ?>
                                                            <?php endif; ?>
                                                            </div>
                                            </div>
                                    </div>
                            </div>
                            <?php } ?>
                            <?php endwhile;?>
    </div>                 
     
    <?php Utilities::get_template_parts( array( 'parts/shared/footer','parts/shared/html-footer' ) ); ?>