Last active
January 30, 2018 18:38
-
-
Save amberhinds/1ce89568da68970dcd5c22b8fe4ca32d to your computer and use it in GitHub Desktop.
Tour Stops Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tour Stops Section | |
if ($tour_stops) { | |
?> | |
<div id="tour-stops" class="tour-stops-sctn"> | |
<div class="wrap"> | |
<h2 class="tour-title">Tour Cities</h2> | |
<div class="tour-stops-upcoming"> | |
<h3>Upcoming Events<h3> | |
<?php | |
$tourstopsfutureargs = array( | |
'post_type' => 'tour-stop', | |
'meta_query' => array( | |
'relation' => 'OR', | |
array( | |
'key' => 'Event_Date', | |
'compare' => '<', | |
'value' => $today, | |
), | |
array( | |
'key' => 'Event_Date', | |
'compare' => 'NOT EXISTS', | |
'value' => '', | |
) | |
), | |
'order' => 'ASC', | |
//'meta_key' => 'Event_Date', | |
'orderby' => 'title', | |
'posts_per_page' => -1, | |
); | |
$tour_stops_future_query = new WP_Query( $tourstopsfutureargs ); | |
if ( $tour_stops_future_query->have_posts() ) { | |
echo '<ul>'; | |
while ( $tour_stops_future_query->have_posts() ) { | |
$tour_stops_future_query->the_post(); | |
$date = get_field('Event_Date'); | |
echo '<li class="city-name">'; | |
echo '<h4><a href="' . get_the_permalink() . '">' . get_the_title(); | |
if ($date) { echo ' | ' . date("F j, Y", strtotime($date)); }; | |
echo '</a></h4>'; | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
} | |
wp_reset_postdata(); | |
?> | |
</div> | |
<div class="tour-stops-past"> | |
<h3>Past Events</h3> | |
<?php | |
$tourstopsargs = array( | |
'post_type' => 'tour-stop', | |
'meta_query' => array( | |
array( | |
'key' => 'Event_Date', | |
'compare' => '>', | |
'value' => $today, | |
) | |
), | |
'order' => 'DSC', | |
'meta_key' => 'Event_Date', | |
'orderby' => 'meta_value_num title', | |
'posts_per_page' => -1, | |
); | |
$tour_stops_query = new WP_Query( $tourstopsargs ); | |
if ( $tour_stops_query->have_posts() ) { | |
echo '<ul>'; | |
while ( $tour_stops_query->have_posts() ) { | |
$tour_stops_query->the_post(); | |
$date = get_field('Event_Date'); | |
echo '<li class="city-name">'; | |
echo '<h4><a href="' . get_the_permalink() . '">' . get_the_title(); | |
if ($date) { echo ' | ' . date("F j, Y", strtotime($date)); }; | |
echo '</a></h4>'; | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
} | |
wp_reset_postdata(); | |
?> | |
</div> | |
<?php if ($about_btn && $about_btn_url) { | |
?> | |
<center><a class="button" href="<?php echo $about_btn_url; ?>"><?php echo $about_btn; ?></a></center> | |
<?php | |
} | |
?> | |
</div> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment