获得更多的WordPress帖子

时间:2015-05-18 04:05:20

标签: javascript angularjs wordpress api http

我试图从WP帐户获得超过默认数量的帖子,默认值为10,我需要至少20,这就是我这样做的方式

getBlogs: function($scope) {
  $scope.postsURL = 'http://urbanetradio.com/wp-json/posts?filter[posts_per_page]=20&filter[order]=ASC_jsonp=JSON_CALLBACK';
  $http.jsonp($scope.postsURL).success(function(data, status, headers, config) {
    $scope.posts = data;
  })
}

这是我正在使用http://wp-api.org/

的插件

here is a Plnuker just in case

如果你把这个链接放在例如POSTMAN中,你得到一个STATUS 200 OK,但在我的应用中,却给了我一个错误。

您认为发生了什么?

1 个答案:

答案 0 :(得分:1)

您的查询字符串格式不正确,即应该读取

div.wrap2
    - var imgs = [[200, 286], [200, 139], [140, 200], [200, 287], [96, 139]];
    - for (var i = 0; i < imgs.length; i++)
        div.group
            input(type="radio" name="test" id="#{i}" value="#{i}" checked="#{input == 3}")
            label(for="#{(i - 1 + imgs.length) % imgs.length}").previous &lt;
            label(for="#{(i + 1) % imgs.length}").next &gt;
            div.content
                p panel ##{i}
                img(src="http://placekitten.com/g/#{imgs[i].join('/')}"
                    height="#{imgs[i][1]}"
                    width="#{imgs[i][0]}"
                )

即。您需要将http://urbanetradio.com/wp-json/posts?filter[posts_per_page]=20&filter[order]=A‌​SC&jsonp=JSON_CALLBACK 参数与&符号_json=...

分开
相关问题