我觉得自己很傻但是我无法弄清楚如何在我的YQL RSS Feed中添加限制我在这里是jsfiddle - 我只想展示最后2个(最近的)博客帖子
YUI().use('node', 'gallery-yql', function(Y) {
new Y.yql('select * from rss where url="http://caremonkeys.co.uk/feed/"',
function(r) {
if (r.query) {
if (r.query.results) {
var res = Y.one('#results'), content = '<ul><li></li>';
Y.each(r.query.results.item,
function(v) {
var the_link=v.link;
var the_title=v.title;
var the_desc=v.description;
var the_image=v.image;
var the_cat=v.category;
content += "<li class="+the_cat+"><a href="+the_link+">"+the_title+"</a>"+the_desc+"<img src="+the_image+"></li>";
});
content += "</ul>";
res.setContent(content);
}}});});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="results">Loading...</div>
&#13;
答案 0 :(得分:1)
Try this,change no_items to wordpress limit,
YUI().use('node', 'gallery-yql', function(Y) {
new Y.yql('select * from rss where url="http://caremonkeys.co.uk/feed/"',
function(r) {
if (r.query) {
if (r.query.results) {
var res = Y.one('#results'), content = '<ul><li></li>';
//
var no_items= 2;
var item = r.query.results.item;
for(var i=0;i<no_items;i++){
var title = item[i].title;
var link = item[i].link;
var desc = item[i].description;
var the_cat = item[i].category;
content += "<li class="+the_cat+"><a href="+the_link+">"+the_title+"</a>"+the_desc+"<img src="+the_image+"></li>";
}
//
content += "</ul>";
res.setContent(content);
}}});});