I have a custom post type ‘license’ with custom post statuses ‘active,inactive,cancel,expire’. However when I run a get_posts query to get only posts with active status it returns all the posts irrespective of the status.

$active_licenses = get_posts( array(
        'post_type' => 'license',
        'post_status'    => 'active',
        'posts_per_page' => -1,
        'orderby'        => 'ID',
        'order'          => 'DESC',

    ) );

I am unable to figure out what am I doing wrong.

2 Answers
2

I would try use 'perm' => 'readable' in your query arguments to make sure WP_Query runs a permissions check.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *