0

I tried using the WP_query and get_posts without success. I need to have a post based on the key/value pair of its postmeta. This is my latest try:

<?php
$args = array(
    'meta_query'        => array(
        array(
            'key'       => "team_leader_subscription_id",
            'value'     => 38
        )
    ),
    'post_type'         => 'novathon-team',
    'posts_per_page'    => '1'
);

// run query ##
$posts = get_posts( $args );
$q=WP_query($args);

print "DEV: posts:<pre>"; print_r($posts);print_r($q); print "</pre>";

It's returning empty array although I know there exists a post which has postmeta team_leader_subscriptions_id as key and 38 as value. Why is this hapening? I also tried using WP_query with this same arguments in different forms and still nothing. What am I missing here?

0

Found an answer. My posts were all in status "private", and by default only the posts with "publish" status are taken.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.