Same query in category.php and in function.php, but different result

Found the answer – the query on the category page had post_status=”publish” by default and the query in the function.php had post_status=”publish” OR post_status=”future” OR post_status=”draft” OR post_status=”pending” as default, so the solution was to be more explicit in the $args and add ‘post_status’ => ‘publish’.