I had a very basic wp_query, below:

// WP_Query arguments
$args = array (
    'post_type'              => array( 'post' ),
    'post_status'            => array( 'draft' ),
    'posts_per_page'         => '15',
);

// The Query
$posts = new WP_Query( $args );

This caused a 500 error. When I changed $posts back to the more traditional $query, everything was fine. Is $posts a reserved variable?

1 Answer
1

Is $posts a reserved variable

Yes, it is, $posts is the global variable which holds the array of posts from the main query. This is how it is set:

$GLOBALS['posts'] = & $wp_query->posts;

Just remember, $posts === $GLOBALS['posts']

Leave a Reply

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