After hours of trying to fix this, I haven’t been able to do it. I know this question has been answered here, but after trying the proposed solutions, I cannot get it to work. No matter if I set numberpost to -1 or 1000, I always get the default 10 posts from get_post(). I know for sure that I have more than 10 posts that would be returned by this query. This is my code:

 $args = array(
        'post_type' => 'cp_library',
        'numberposts' => -1,
        'tax_query' => array(
            array(
                'taxonomy' => 'cp_library',
                'field' => 'slug',
                'terms' => array('basic')
            )
        )
    );
    $posts_list = get_posts($args);
    print_r(count($posts_list));//Prints 10

It seems to me that I’m doing things the right way, according to the codex and other answers here, but nonetheless, it is not working.

Any help is highly appreciated.

Read more here: get_post() not returning all the posts, even when using numberposts => -1


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: