dsafew1231 2016-03-21 18:52
浏览 33

WordPress:按月分组帖子?

is there a way to do this ?

August 2009
11 Title of the post of the 11th day of August
15 Title of other post of the 15th day of August
20 Title of another post of the 20th day of August

July 2009
4 Title of the post of the 4th day of July
7 Title of other post of the 7th day of July
15 Title of another post of the 15th day of July

i need group this post by custom metabox evmeta_test_textdate

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$format_of_date = 'Y/m/d';
$oldest = date($format_of_date, strtotime('-30 days'));
$args=array(
  'meta_key'=> 'evmeta_test_textdate',
  'meta_value'=> $oldest,
  'meta_compare'=> '>=',
  'post_type' => 'upg',
  'post_status' => 'publish',
  'order' => 'ASC',
  'paged' => $paged,
);
$query = new WP_Query( $args );

Thanks!

  • 写回答

1条回答 默认 最新

  • douye4051 2016-03-21 19:01
    关注

    The default behavior for Wordpress is to handle dates by publication date and query in the following format:

    $args = array(
        'date_query' => array(
            array(
                'year'  => 2012,
                'month' => 12,
                'day'   => 12,
            ),
        ),
    );
    $query = new WP_Query( $args );
    

    Is there a particular reason why should you handle dates by custom meta?

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line