理想情况下,我只想显示将来的帖子/事件(今天和将来的事件),但按开始日期排序。现在,隐藏过去事件的功能正在起作用,但是顺序是按“结束日期”排序的,我想按“开始日期”排序。
/*
Events Category Template
*/
// get posts
$posts = array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
'category_name' => 'agenda',
//'orderby' => 'meta_value_num',
'meta_key' => "event_date_end",
'meta_compare' => '>=',
'meta_value' => date_i18n("Ymd"),
'orderby' => 'meta_value',
'order' => 'ASC',
);
$posts=get_posts($posts);
get_header(); ?>
<div id="main-content">
<div class="container">
<h1 class="cat-title"><?php echo single_cat_title(); ?></h1>
<div id="content-area" class="clearfix">
<div id="left-area">
<?php if( $posts ): ?>
<?php foreach( $posts as $post ):
setup_postdata( $post );?>
<!-- content goes here -->
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div> <!-- #left-area -->
<?php get_sidebar(); ?>
</div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->
<?php
get_footer();
开始日期自定义字段:event_date_start
结束日期自定义字段:event_date_end