Wordpress按自定义元值日期对帖子排序

时间:2017-02-21 12:00:41

标签: php wordpress date meta

这是我查询帖子的代码,但它不起作用。我有这样的日期格式:dd.mm.yyyy

我改变了格式几次,但它仍然无效。

$args = array(
'meta_query' => array(
    array(
        'key' => 'gestorben',
        'value' => date('dd.mm.yyyy'),
        'type' => 'DATE'
    )
),
'post_type'        => 'traueranzeigen',
'showposts'        => 10,
'paged'            => $paged,
'suppress_filters' => $suppress_filters, 
    'meta_key' => 'gestorben', 
    'orderby' => 'meta_value', 
    'order' => 'DSC'
);

我希望你能帮助我

1 个答案:

答案 0 :(得分:2)

谢谢它现在有效

$args = array(
    'post_type'        => 'traueranzeigen',
    'showposts'        => 10,
    'paged'            => $paged,
    'suppress_filters' => $suppress_filters, 
    'meta_key'         => 'gestorben',
    'meta_type'        => 'DATETIME', 
    'orderby'          => 'meta_value_datetime', 
    'order'            => 'ASC'
);