【问题标题】:Sorting wordpress posts with ACF date & time picker使用 ACF 日期和时间选择器对 wordpress 帖子进行排序
【发布时间】: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


    【解决方案1】:

    我什么都没做,只是重新上传了模板文件,它就开始正确排序了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      • 2018-12-31
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      相关资源
      最近更新 更多