我有想要按自定义字段排序的帖子...我正在为我的自定义字段使用高级自定义字段插件。这是我的代码...请帮我修改它,以便帖子将按 start_day 自定义字段排序...
$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
}