简体   繁体   中英

Display posts from blog offset by 3 with jQuery/javascript

I am using jquery-rss to display the latest posts on a web page. What I want is to display 3 posts, but not the three latest, the three after that. So if I were to pull through the top 6 it would display the last 3.

Post 1 - Not displayed Post 2 - Not displayed Post 3 - Not displayed Post 4 Post 5 Post 6

How would I approach this with javascript or jQuery?

    <script type="text/javascript">
  jQuery(function($) {
    $("#rss-feeds").rss("http://news.bearingnet.net/feed/", {

      layoutTemplate: "<div class='feed-container'>{entries}</div>",
      entryTemplate: "<div class='rssEntry'><p class='padding-top'>{teaserImage}<a href='{url}' target='_blank'>{title}</a><br /> {date} <br />{shortBodyPlain}...<div class='text-right'></p><p><a href='{url}' target='_blank' class='btn main-bg'>Read more</a></p></div></div>",
    })
  })

</script>

Sorry to be sarcastic - but it clearly is an advantage if you just READ the letters of the docs.

$("#rss-feeds").rss(
  "http://feeds.feedburner.com/premiumpixels",
  {
    // how many entries do you want?
    // default: 4
    // valid values: any integer
    limit: 10,

    // want to offset results being displayed?
    // default: false
    // valid values: any integer
    offsetStart: 3, // offset start point
    offsetEnd: false, // offset end point

    // will request the API via https
    // default: false
    // valid values: false, true
    ssl: true,
.....

Right from the documentation page..

Look for offsetStart . That should do it. The whole process: googleing "jquery-rss" looking for your answer, took me around 15 seconds. This has nothing to do with showing off.. I'm just trying to open some eyes.

Update/Edit:

OK, so.. having a look at the discussion below in the comments, I'll just throw in another solution or better workaround which is kind of awkward, and only because the other options don't seem to work.

You can simply hide the first three RSS posts with these css-rules:

.feed-container:first-of-type {
    display: none;
}
.feed-container:nth-of-type(2) {
    display: none;
}
.feed-container:nth-of-type(3) {
    display: none;
}

This workaround simply hides the first three posts. It is neither elegant, nor the right way to do it - but it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM