我搜索了此问题,并尝试了几种没有运气的解决方案。
我的主要路线在这里:https : //cnperformance.wpengine.com/wp-json/wp/v2/products?_embed
我安装了“ WP REST API过滤器参数”插件,以还原当REST API移至WordPress核心时删除的过滤器。
我试过了:https : //cnperformance.wpengine.com/wp-json/wp/v2/products?_embed&?filter[per_page]=-1
和
https://cnperformance.wpengine.com/wp-json/wp/v2/products?_embed&?filter[posts_per_page]=-1
我也在functions.php中尝试过
add_filter( 'rest_endpoints', function( $endpoints ){
if ( ! isset( $endpoints['/wp/v2/products'] ) ) {
return $endpoints;
}
unset( $endpoints['/wp/v2/products'][0]['args']['per_page']['maximum'] );
return $endpoints;
});
Run Code Online (Sandbox Code Playgroud)
参考在这里:https : //github.com/WP-API/WP-API/issues/2316
我已将posts_per_page的值设置为100,-1,没有区别。我还尝试仅添加参数'&posts_per_page = -1而不使用过滤器查询,但这也不起作用。任何帮助或见解,不胜感激!