【发布时间】:2017-07-26 17:24:12
【问题描述】:
我正在使用 ACF pro 日期和时间选择器来填充自定义帖子类型“fixtures”的字段“fixture_date”。运行 new wp_Query 会返回所有帖子,但我无法按自定义字段的日期和时间对它们进行排序。
日期和时间选择器设置为在 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>
【问题讨论】:
标签: php wordpress advanced-custom-fields