我想按一个名为date_start
但是,如果我已经有了一个元密钥,那么如何为其包含一个元密钥呢?
$currentshowid = get_the_ID();
$today = date(\'Y-m-d\');
$args = array(
\'meta_key\' => \'show_id\',
\'meta_value\' => $currentshowid,
\'orderby\' => \'meta_value_num\',
\'order\' => ASC,
\'meta_query\' =>array(
\'relation\' => \'AND\',
array(
\'key\' => \'date_end\',
\'value\' => $today,
\'compare\' => \'>=\',
),
),
);
SO网友:Chinmoy Kumar Paul
您需要为自定义字段使用类型参数。试试这个
<?php
$currentshowid = get_the_ID();
$today = date(\'Y-m-d\');
$args = array(
\'meta_key\' => \'show_id\',
\'meta_value\' => $currentshowid,
\'orderby\' => \'meta_value_num\',
\'order\' => ASC,
\'meta_query\' =>array(
\'relation\' => \'AND\',
array(
\'key\' => \'date_end\',
\'value\' => $today,
\'compare\' => \'>=\',
\'type\' => \'date\'
),
),
);