dongzhan1383 2014-06-06 01:14
浏览 82

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

I am working in a child theme and need to the category posts to be sorts by the custom field date rather than the wordpress publish date. Can anyone point me in the right direction?

This is what I have in my content-single.php file:

        <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 -->

I am very new to php and wordpress. I am working in a child theme. What code do I need to add so that the posts order by the custom field date and where exactly do I need to put it?

  • 写回答

1条回答 默认 最新

  • drzfz9995 2014-06-10 03:36
    关注

    You can simply specify in your WP_query() :

    See for examples : http://codex.wordpress.org/Function_Reference/WP_Query#Order_.26_Orderby_Parameters

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集