【发布时间】:2018-11-02 21:11:04
【问题描述】:
我搜索了这个问题并尝试了几种解决方案,但都没有成功。
我的主要路线在这里: 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;
});
参考这里:https://github.com/WP-API/WP-API/issues/2316
我已将posts_per_page 的值设置为100,-1,没有任何区别。我还尝试只添加参数 '&posts_per_page=-1 而不使用过滤器查询,但这也不起作用。非常感谢任何帮助或见解!
【问题讨论】:
-
也许试试这个
https://cnperformance.wpengine.com/wp-json/wp/v2/products?_embed&per_page=100 -
我敢打赌,钱是行不通的,但它确实奏效了!本可以发誓我已经尝试过,但一定是在格式上关闭了。谢谢!!!
-
请在此处查看我对这个问题的回答:stackoverflow.com/a/54382455/1211184
-
@kurtg 你能把我的答案标记为正确的还是有什么不清楚的地方?
标签: wordpress custom-post-type wordpress-rest-api wp-api