Skip to content

Instantly share code, notes, and snippets.

@oliwa
Created October 25, 2016 08:43
Show Gist options
  • Select an option

  • Save oliwa/1be2c8007d3e91f4718c4026eff25c40 to your computer and use it in GitHub Desktop.

Select an option

Save oliwa/1be2c8007d3e91f4718c4026eff25c40 to your computer and use it in GitHub Desktop.
Custom Post Type Query (Events)
<?php
$today = date_i18n('Ymd');
$args = array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_key' => 'event_date',
'meta_compare' => '>=',
'meta_value' => $today,
'orderby' => 'meta_value',
'order' => 'asc',
);
$events = new WP_Query( $args );
?>
<?php if( $events->have_posts() ) { ?>
<?php while( $events->have_posts() ) { $events->the_post(); ?>
<?php get_template_part('includes/loop-events'); ?>
<?php } // end while ?>
<?php wp_reset_postdata(); ?>
<?php } // end if ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment