admin管理员组

文章数量:1287120

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 3 years ago.

Improve this question

I'm trying to list all my product brands in a single page, currently i'm able to get only 100 brands per page by using wp-json/wc/v3/products/brands?per_page=100. but if i set per_page=200, i'm getting status 400 with the following error

{"code":"rest_invalid_param","message":"Invalid parameter(s): per_page","data":{"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"}}}

is there any way i can set a maximum limit to 200 in the functions.php. I checked the documentation, i couldn't find anything that is useful.

Please note that i already set the maximum query limit for products like this in the functions.php

add_filter('rest_product_collection_params', 'maximum_api_filter');
function maximum_api_filter($query_params) {
    $query_params['per_page']["maximum"]=300;
    return $query_params;
}
   

is there a similar way to achieve this for brands also ?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 3 years ago.

Improve this question

I'm trying to list all my product brands in a single page, currently i'm able to get only 100 brands per page by using wp-json/wc/v3/products/brands?per_page=100. but if i set per_page=200, i'm getting status 400 with the following error

{"code":"rest_invalid_param","message":"Invalid parameter(s): per_page","data":{"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"}}}

is there any way i can set a maximum limit to 200 in the functions.php. I checked the documentation, i couldn't find anything that is useful.

Please note that i already set the maximum query limit for products like this in the functions.php

add_filter('rest_product_collection_params', 'maximum_api_filter');
function maximum_api_filter($query_params) {
    $query_params['per_page']["maximum"]=300;
    return $query_params;
}
   

is there a similar way to achieve this for brands also ?

Share Improve this question asked Feb 17, 2021 at 7:14 Asif RahmanAsif Rahman 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

There are no brand fields in WooCommerce core by default. This answer comes from a post 2 years ago, given by an engineer from Automattic. I double-checked the validity of this answer again today.

Yes correct use vendor_id or another field which is valid. Let me share mine which was worked for me.

i place exactly same code in function.php file.

add_filter('rest_product_collection_params', 'maximum_api_filter'); function maximum_api_filter($query_params) { $query_params['per_page']["maximum"]=300; return $query_params; }

but my filter was like-

wp-json/wc/v3/products?status=publish&vendor_id=13&lang=en&per_page=300&

本文标签: Woocommerce REST APIadd filter to set maximum query per page for product brands