When calling WP_Query
directly, you should use posts_per_page
and not numberposts
— it is an alias for posts_per_page
, but only used with get_posts()
.
// These work, but I strongly advise against using 999:
$fs_ski_resorts = get_posts( array( 'numberposts' => 999 ) );
$fs_ski_resorts = get_posts( array( 'posts_per_page' => 999 ) );
$the_query = new WP_Query( array( 'posts_per_page' => 999 ) );
// This doesn't work:
$the_query = new WP_Query( array( 'numberposts' => 999 ) );
As for disabling the pagination, via WP_Query
, it can be done using the nopaging
parameter, but I suggest you to always enable pagination, which defaults to max 100 posts/items per page in the REST API. See https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/#pagination-parameters:
Large queries can hurt site performance, so
per_page
is capped at
100 records. If you wish to retrieve more than 100 records, for
example to build a client-side list of all available categories, you
may make multiple API requests and combine the results within your
application.