Wordpress WP_Query“NOT IN”无效

时间:2016-10-18 10:28:46

标签: php wordpress

我有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;

1 个答案:

答案 0 :(得分:0)

使用此代码并确保您在$ REQUEST ['uid']

中获得价值
WITH
-- CTE to generate the same data
tree AS (
   SELECT 1 AS node, 0 AS parent
   UNION ALL SELECT 2, 1
   UNION ALL SELECT 3, 1
   UNION ALL SELECT 4, 2
   UNION ALL SELECT 5, 2
   UNION ALL SELECT 6, 3
   UNION ALL SELECT 7, 3
)
SELECT
   node,
   parent,
   DENSE_RANK() OVER (ORDER BY parent) AS your_rank
FROM tree;