我试图找出wp\\U查询的这两个参数设置之间的实际差异
$today= date(\'Ymd\');
$homepageEvents = new WP_Query(array(
\'post_type\' => \'event\',
\'posts_per_page\' => -1,
\'orderby\' => \'meta_value_num\',
\'meta_key\' => \'event_date\',
\'order\' => \'ASC\',
\'meta_query\' => array(
array(
\'key\' => \'event_date\',
\'compare\' => \'>=\',
\'value\' => $today,
\'type\' => \'numeric\'
)
)
));
vs公司
$today= date(\'Ymd\');
$homepageEvents = new WP_Query(array(
\'post_type\' => \'event\',
\'posts_per_page\' => -1,
\'orderby\' => \'event_date\',
\'order\' => \'ASC\',
\'meta_query\' => array(
array(
\'key\' => \'event_date\',
\'compare\' => \'>=\',
\'value\' => $today,
\'type\' => \'numeric\'
)
)
));
唯一的区别在于,它被设置为
orderby
使用参数
meta_value_num
然后需要在字段名中添加一个元键集。另一方面
orderby
只使用字段名本身。
这是否会导致相同的查询,或者我问了两个恰好有相同答案的问题?