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>