根据您的评论:
它在没有array( \'key\' => \'picture_url\', \'value\' =>
\'none\', \'compare\' => \'!=\' )
但我需要把它包括在查询中。。。有可能吗?
是,使用named sub-meta queries 像这样:
$q_args = [
// ... other args here ...
\'meta_query\' => [
\'picture_url\' => [ \'key\' => \'picture_url\', \'value\' => \'none\', \'compare\' => \'!=\' ],
\'totalviews\' => [ \'key\' => \'totalviews\', \'value\' => \'0\', \'compare\' => \'>=\', \'type\' => \'NUMERIC\' ],
],
\'orderby\' => \'totalviews\', // set this to a key in the above meta queries
\'order\' => \'DESC\',
];
The
orderby
参数也可以是数组:
\'orderby\' => [
\'totalviews\' => \'DESC\', // sort by meta_query key
\'picture_url\' => \'ASC\', // sort by meta_query key
\'date\' => \'DESC\', // sort by the post date
]
以及(再次),
orderby
不是中数组的有效参数
meta_query
大堆看见
here 了解更多详细信息。