Doing a simple query and ordering by event date
-
So, the main thing that interested me about Event Manager was its use of custom post types. However, I’m trying to run a simple query and cannot order them by their event start date. Here’s my code:
<?php $args = array( 'post_type' => 'event', 'posts_per_page'=>-1, 'orderby' => 'event_start_date', 'order' => 'ASC' ) ?> <?php $my_query = new WP_Query($args); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <article class="happening_ListItem clearfix"> <a title="View Event" class="happening_OpenLink" href="<?php the_permalink(); ?>">+</a> <div class="happening_ListDate"> <div class="happening_ListDateInner"> <div class="happening_Month"><?php the_time('F'); ?></div> <div class="happening_Day"><?php the_time('j'); ?></div> <div class="happening_Year"><?php the_time('Y'); ?></div> </div> </div> <div class="happening_ListDescription"> <div class="happening_ListName"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </div> <div class="happening_ListMeta"> <p><?php echo wp_trim_words( get_the_content(), 20, '...' ) ?></p> </div> </div> </article> <?php endwhile; wp_reset_postdata();?>All I’m trying to do is list the posts in order. Additionally, is there a way to only show future events this way? Any help here would be greatly appreciated.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Doing a simple query and ordering by event date’ is closed to new replies.