Crafting WP_Query array, sort by date

question about wordpress WP_Query:

‘post_type’ => ‘event_date’ outputs dd/mm/yy ex: 31122012

Read More

I would like to order my frontend ‘event_date’ output not by latest WP post entry
but by latest ‘event_date’

Already tried ‘order’ => ‘ASC’ that sort only on WP post entry

Heres my code:

$arg = array('post_type' => 'livedates');
$the_query = new WP_Query($arg);
while($the_query->have_posts()) : $the_query->the_post();
$date = str_split(get_post_meta($post->ID, 'event_date', true), 2);

//the loop

endwhile;

Related posts

Leave a Reply

1 comment

  1. You can sort a query by a specified post meta field as a number or as a text field.
    Example:

    $query_args = array(
                'meta_key' => 'event_date',
                'orderby' => 'meta_value_num'
     );
     $event_query = new WP_Query( $query_args );