Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Created December 10, 2013 17:25
Show Gist options
  • Save michaelschofield/7894479 to your computer and use it in GitHub Desktop.
Save michaelschofield/7894479 to your computer and use it in GitHub Desktop.
Basic WP_Query() for ordering the loop by a custom field (i.e., start_date).
$args = array(
'meta_key' => 'start_date',
'orderby' => 'meta_value_num',
'post_type' => 'events'
);
$events = new WP_Query( $args );
if ( $events->have_posts()) : while ( $events->have_posts()) : $events->the_post();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment