new WP_query using custom fields

Question

I am trying to query child posts from two parents (that part is working fine),

… but now I want to exclude posts that have a meta_key of ‘feature’ with a meta_value of ‘1’

Using the Codex reference I’ve tried a couple of ways to write this, not working.

Here’s what I’ve written thus far, I believe I’m close, but need help.
Thank you!

<?php
    $argsthis = array(
    'post_status' => 'publish',
    'post_type' => 'page',
    'order' => 'DESC',
    'posts_per_page' => '5',
    'post_parent__in' => array(10,11),
    'meta_query' => array(
      array(
            'key'     => 'feature',
            'value'   => '1',
            'compare' => '!=',
            ),
        )
    );
?>

and I’ve tried, simply (w exact same result as above):

<?php
    $argsthis = array(
    'post_status' => 'publish',
    'post_type' => 'page',
    'order' => 'DESC',
    'posts_per_page' => '5',
    'post_parent__in' => array(10,11),
    'meta_key'     => 'feature',
    'meta_value'   => '1',
    'meta_compare' => '!=',
            ),
        )
    );
?>
0
, ccbar 3 years 2020-06-05T06:11:12-05:00 0 Answers 91 views 0

Leave an answer

Browse
Browse