0
我使用ACF专业日期&时间选择器为自定义帖子类型“fixtures”填充字段“fixture_date”。运行new wp_Query
会返回所有帖子,但我无法通过自定义字段的日期&时间对它们进行排序。使用ACF日期和时间选择器对wordpress文章进行排序
日期&时间选取器设置为从ACF Pro内输出为j F Y - g:i a
。
我迄今为止代码:
<table id="fixturestable">
<tbody>
<?php $args = array(
'post_type' => 'fixtures',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'fixture_date',
'order' => 'ASC',
'meta_type' => 'DATETIME'
);
$fixturesloop = new WP_Query($args); if ($fixturesloop->have_posts()):?>
<?php while ($fixturesloop->have_posts()) : $fixturesloop->the_post();?>
<tr>
<td class=""><?php the_title(); ?></td>
<td class=""><?php echo(get_field('fixture_date'));?></td>
<td class=""><?php echo(get_field('competition'));?></td>
<td class=""><?php echo(get_field('venue'));?></td>
<td class=""><?php echo(get_field('result'));?></td>
<td class=""><?php echo(get_field('score'));?></td>
</tr>
<?php endwhile;?>
<?php endif;?>
</tbody>
</table>