查询查询运行得很好http://solucase.com/wp-json/wp/v2/posts?categories=38
但是,当我将其添加到循环函数以获取与该类别相关的所有帖子时,我会在检查链接技术时收到此错误,例如
function postsPerCat(cat_id) {
$.ajax({
method : \'GET\',
dataType : \'json\',
success : \'success\',
url : "http://solucase.com/wp-json/wp/v2/posts?categories=\'cat_id\'",
})
.then(function (posts) {
$.each(
posts,
function(key, val) {
$(\'.recentposts\')
.append(
\'<div class="post" data-icon="false" onclick=postDetails(\'
+ val.id
+ \')><a href="#postview"><img src=\'
+ val._embedded[\'wp:featuredmedia\'][\'0\'].media_details.sizes.thumbnail.source_url
+ \' ></img></a><h1 class="post_h1">\'
+ val.title.rendered
+ \'</h1></div>\'
)
;
$(\'.recentposts\').listview(\'refresh\');
}
);
});
}