[英]Wordpress JSON API
Hey guys i have been so far in luck with the JSON API i love it but i encouter this little problem with it comes to making multiple query in the same custom function. 嘿,我到目前为止对JSON API感到很幸运,我喜欢它,但是我可以解决这个小问题,它涉及在同一个自定义函数中进行多个查询。
global $json_api;
$result = array();
$category = $json_api->introspector->get_categories();
foreach($category as $value){
if($value->id !== 1 && $value->id !== 69 && $value->id !== 68 && $value->id !== 66){
$search_args = array(
'cat' => $value->id,
'order' => 'DESC',
'post_status' => 'publish'
);
$search_limits = array(
10 => array(
'limit' => 4
),
5 => array(
'limit' => 2
),
3 => array(
'limit' => 3
)
);
$json_api->query->count = ($search_limits[$value->id]['limit'] === null ? 1 : $search_limits[$v$
$result['posts'][$value->id] = $json_api->introspector->get_posts($search_args,true);
}
}
return $result;
i hardcoded some of the values just to make it more straight foward, the issue is that when i make one query i get value ID lets say [10330][10218][10202] according to the category im looking for. 我对某些值进行了硬编码,只是为了使其更加直观,问题是当我进行一个查询时,我得到的值ID根据要查找的类别说[10330] [10218] [10202]。 Then i make this same query but with another category ID. 然后我进行相同的查询,但具有另一个类别ID。 But same result happens. 但是同样的结果发生了。 So i was wondering is due to some sort of caching in the API if so can i turn it off for this query ? 所以我想知道是由于API中的某种缓存是否可以针对该查询将其关闭?
Thanks in advance :D 提前致谢
Well what do you expect the issue is that i was not reseting my queries apparently. 那么,您期望的问题是我显然没有重置查询。
wp_reset_query();
did the trick. 做到了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.