I have a rss feed project that I am working on Question: I would like to know if there is a way of only displaying 5 result at a time.

Currently it displays over 10

Codepen Example

$(document).ready(function() {
  url = 'http://codepen.io/riwakawebsitedesigns/public/feed/';
  $.ajax({
    type: "GET",
    url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(url),
    dataType: 'json',
    error: function() {
      alert('Unable to load feed, Incorrect path or invalid feed');
    },
    success: function(xml) {
      var postlist = xml.responseData.feed.entries;
      var html = '<ul class="list-unstyled">';
      $.each(postlist, function(idx, data) {
        var title = data.title;

        html += '<li>';
        html += '<h3 class="codepen_feed_title">' + data.title + '</h3>';
        html += '<a href="http://codepen.io/riwakawebsitedesigns/"' + title + '/">';
        html += '<span class="codepen_feed_content">Click Here To View It!</div>';
        html += '</a>';
        html += '</li>';
      });
      html += '</ul>';
      $(".codepen_feed").append(html);
    }
  });
});
Member Avatar for diafol

$.each is ensuring that all postlist items are included. Use a for loop instead.

Mind you - is the num parameter (=1000) in the URL the issue. Will changing it to =5 work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.