I have posts which I want to order by custom fields ... I'm using Advanced Custom Fields plugin for my custom fields. here is my code... pleas help me to modify it so that the posts would be orderd by start_day custom field...
$today = date('Y-m-d');
$cat = get_term_by('name', 'events', 'category');
$args = array('cat' => $cat->term_id, 'posts_per_page' => -1, 'meta_query' => array(
array(
'key' => 'end_date',
'value' => $today,
'type' => 'DATE',
'compare' => '>=',
'meta_key' => '_date',
"orderby" => "start_date",
"order" => "ASC"
)));
$posts = get_posts($args);
foreach($posts as $post) {
setup_postdata($post);
if((date("j", strtotime(get_field('start_date')))+1 || date("j", strtotime(get_field('start_date')))) !=date("j", strtotime(get_field('end_date')))){
$data_info = date("F", strtotime(get_field('end_date')))." ".date("d", strtotime(get_field('start_date')))."-".
date("d", strtotime(get_field('end_date')));
}else{
$data_info = date("F", strtotime(get_field('end_date')))." ".date("d", strtotime(get_field('start_date')));
}
?><div class="fEventFront">
<?php
if (has_post_thumbnail($post->ID)):
$thumbnail = wp_get_attachment_image_src ( get_post_thumbnail_id($post->ID), array(55,55));
$full = wp_get_attachment_image_src ( get_post_thumbnail_id($post->ID), 'Large');
?>
<div class="fEventFrontThumb">
<img width="55" src="<?php echo $thumbnail[0];?>" alt=""/>
</div>
<?php endif; ?>
<div class="fEventFrontText">
<div class="fEventFrontTitle"><span class="date_info"><?php echo $data_info?> </span><?php the_title() ?></div>
<div class="fEventFrontDescription"><?php the_field('short_description') ?></div>
</div>
</div><?php
}