• Resolved woogychuck

    (@woogychuck)


    When calling the get_posts function, I’m look for all posts that have a CustomField named ‘ShowNav’ that has a value of ‘false’

    I have confirmed that there are multiple published posts with this key/value combination, but both of the following function calls return an empty array.

    $postlist = get_posts('meta_key=ShowNav');
    
    $postlist = get_posts('meta_key=ShowNav&meta_value=false');
    
    $args = array(
    	'meta_key' => 'ShowNav',
    	'meta_value' => 'false'
    	);
    $postlist = get_posts($args);

    I’m actually using 2.9.2, but it wasn’t an option in the select

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter woogychuck

    (@woogychuck)

    Please disregard this, it was a user error on my part. I mistakenly thought this function would return posts and pages, when it only returns posts.

    What about:

    $args = array(
    	'meta_key' => 'ShowNav',
    	'meta_value' => 'false',
            'post_type' => 'any'
    	);

    or

    $args = array(
    	'meta_key' => 'ShowNav',
    	'meta_value' => 'false',
              'post_type' => array('post','page')
    	);

    Is it possible to get_posts and filter them more than one meta key?

    Is it possible to get_posts and filter them more than one meta key?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘meta_key not return results in get_posts’ is closed to new replies.