按高级自定义字段中输入的日期(日期选择器)对Wordpress帖子进行排序

时间:2014-06-06 01:14:05

标签: php wordpress posts advanced-custom-fields postorder

我正在处理子主题,并且需要按自定义字段日期而不是wordpress发布日期对类别帖子进行排序。有人能指出我正确的方向吗?

这就是我在content-single.php文件中的内容:

        <h1 class="info"><?php the_field('start_date'); ?> - <?php the_field('end_date'); ?></h1>
        <h1 class="info"><?php the_field('time'); ?></h1>
        <h1 class="info"><?php the_field('venue'); ?></h1>
        <a href="<?php the_field('tickets_link'); ?>"><h1 class="buytix">BUY TICKETS<?php the_field('buy_tickets'); ?></h1></a>

        <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'vantage' ) ); ?>
        <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'vantage' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->

我是php和wordpress的新手。我正在以儿童为主题。我需要添加哪些代码,以便帖子按自定义字段日期排序,以及我需要在哪里放置它?

1 个答案:

答案 0 :(得分:0)

您只需在WP_query()中指定:

参见示例: http://codex.wordpress.org/Function_Reference/WP_Query#Order_.26_Orderby_Parameters

相关问题