我从事的一个项目展示了一些旅行(取决于目的地类别)。我尝试在开始日期(var\\u confirmed\\u date)对旅行进行排序,但结果与未排序相同。
以下是我的疑问:
`$args = array(
\'posts_per_page\' => -1,
\'post_type\' => \'product\',
\'meta_value\' => \'meta_value\',
\'meta_key\' => \'var_confirmed_date\',
\'order\' => \'ASC\',
\'meta_type\' => \'DATE\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'destination\',
\'field\' => \'id\',
\'terms\' => array($t_id)
)
),
\'meta_query\' => array(
array(
\'key\' => \'var_confirmed_date\',
\'value\' => date("Y-m-d",time()),
\'compare\' => \'>=\',
\'type\' => \'DATE\',
),
),
);
$loop = new WP_Query( $args );`
有没有办法让它正常工作?
谢谢
SO网友:Valerii Vasyliev
Try this
$args = array(
\'posts_per_page\' => -1,
\'post_type\' => \'product\',
\'meta_key\' => \'var_confirmed_date\',
\'meta_type\' => \'DATE\',
\'orderby\' => \'meta_value_date\',
\'order\' => \'ASC\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'destination\',
\'field\' => \'id\',
\'terms\' => array($t_id)
)
),
\'meta_query\' => array(
array(
\'key\' => \'var_confirmed_date\',
\'value\' => date("Y-m-d",time()),
\'compare\' => \'>=\',
\'type\' => \'DATE\',
),
),
);
$loop = new WP_Query( $args );