You could try this which is mostly code clean up but may solve your problem. I removed the relation
from meta_query
as it’s only needed if you have multiple meta keys in your query, which you don’t. I’ve also replaced the rewind_posts()
with wp_reset_postdata()
and finally, you were ending your IF
statements earlier than your UL
tags, which if it is false you’ll have orphan </ul>
‘s hanging around which is never good.
<h1>2013-14 Concert Season</h1>
<?php
$today = date('Ymd');
$args1 = array(
'type' => 'post',
'category_slug' => 'Featured1314',
'meta_key' => 'concert_date',
'meta_query' => array(
array(
'key' => 'concert_date',
'value' => $today,
'compare' => '>='
)
),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$upcoming_query = new WP_Query($args1);
if( $upcoming_query->have_posts() ) { ?>
<h2>Upcoming Concerts</h2>
<ul><?php while ( $upcoming_query->have_posts() ) { $upcoming_query->the_post(); ?>
<li id="post-<?php the_ID(); ?>"><h1><a href="https://wordpress.stackexchange.com/questions/149415/<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1><p><?php the_excerpt() ?></p></li>
<?php } // endwhile ?>
</ul>
<?php } // endif;
wp_reset_postdata();
$args2 = array(
'type' => 'post',
'category_slug' => 'Featured1314',
'meta_key' => 'concert_date',
'meta_query' => array(
array(
'key' => 'concert_date',
'value' => $today,
'compare' => '<'
)
),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$past_query = new WP_Query($args2);
if( $past_query->have_posts() ) {?>
<h2>Past Concerts</h2>
<ul><?php while ( $past_query->have_posts() ) { $past_query->the_post(); ?>
<li id="post-<?php the_ID(); ?>"><h1><a href="https://wordpress.stackexchange.com/questions/149415/<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1><p><?php the_excerpt() ?></p></li>
<?php } //endwhile; ?>
</ul>
<?php } // endif;