Nice, I've taken a similar approach on posts from multiple sources before. I would just like to point out that this use case is one of the ones where the backend, assuming you control it [ even though it's PHP (gross) ] is probably the better way to go ( primarily because the response time will be much faster than doing multiple queries ). You can use a filter on the rest_[your-post-type]_collections_params like so
function cpt_custom_max_per_page( $params ) {
if ( isset( $params['per_page'] ) ) {
$params['per_page']['maximum'] = *value of your choice*;
}
return $params;
}
$cpts = ['dancers', 'team_members', 'crew_members', 'locations', 'cats', 'pages'];
foreach( $cpts as $cpt ){
$post_params_hook = 'rest_' . $cpt . '_collection_params';
add_filter( $post_params_hook, 'cpt_custom_max_per_page', 10, 1 );
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice, I've taken a similar approach on posts from multiple sources before. I would just like to point out that this use case is one of the ones where the backend, assuming you control it [ even though it's PHP (gross) ] is probably the better way to go ( primarily because the response time will be much faster than doing multiple queries ). You can use a filter on the
rest_[your-post-type]_collections_params
like so