[英]Wordpress WP_Query “NOT IN” not working
我有一個自定義字段, Field Name: "participants"
, Field Type: "User"
。
我想在元查詢中使用“ NOT IN”,但它不起作用。
$getUid = $_REQUEST['uid'];
$args = [
'post_type' => 'polls',
'post_status' => 'publish',
'meta_query' => [
'relation' => 'AND',
[
'key' => 'participants',
'value' => [$getUid],
'compare' => "NOT IN"
]
]
];
$the_query = new WP_Query($args);
return $the_query;
使用此代碼,並確保您獲得$ REQUEST ['uid']的價值
$getUid = $_REQUEST['uid'];
$meta_query_args = array(
'relation' => 'AND', // Optional, defaults to "AND"
array(
'post_type' => 'polls',
'post_status' => 'publish',
'key' => 'participants',
'value' => [$getUid],
'compare' => "NOT IN"
)
);
$meta_query = new WP_Meta_Query( $meta_query_args );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.