There is nothing wrong in your query, but there is some code (a plugin?) that remove from results the posts in the category having term id 1 or 4. (Normally category with term id 1 is ‘uncategorized’)
You can notice that looking at request performed
AND ( wp_posts.ID NOT IN (
SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (1,4)
)
and at 'category__not_in'
query var:
'category__not_in' =>
array (size=2)
0 => int 4
1 => int 1
Now its seems that category__not_in
argument is added using pre_get_posts
action.
If my guess is correct, you can try to remove all actions from that hook to prevent any query modification:
global $wp_filter;
$pgp_hooks = FALSE;
if ( isset( $wp_filter['pre_get_posts'] ) ) {
// save hooks
$pgp_hooks = $wp_filter['pre_get_posts']);
// remove hooks
unset( $wp_filter['pre_get_posts'] );
}
// set 'suppress_filters' param to true to skip sql filters
$args = array(
'posts_per_page' => -1, 'post_type' => 'post', 'suppress_filters' => true
);
// query
$all_posts_query = new WP_Query( $args );
// reset hooks after query is performed
if ( $pgp_hooks !== FALSE ) {
$wp_filter['pre_get_posts'] = $pgp_hooks;
}
// loop goes here...