Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3232362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:09:08+00:00 2026-05-17T17:09:08+00:00

I am running and using the zRSSFeed jQuery plugin (http://www.zazar.net/developers/zrssfeed/) to pull feed items

  • 0

I am running and using the zRSSFeed jQuery plugin (http://www.zazar.net/developers/zrssfeed/) to pull feed items from my WordPress blog and display a single feed item within a seperate XHTML file (outside of the WordPres blog). It works perfectly displaying the latest item in the feed specified.

I would like it to display a RANDOM item from the feed through, rather than just the latest or newest item.

Could the code be amended to do this, and if so how?

/**
 * Plugin: jquery.zRSSFeed
 * 
 * Version: 1.0.1
 * (c) Copyright 2010, Zazar Ltd
 * 
 * Description: jQuery plugin for display of RSS feeds via Google Feed API
 *              (Based on original plugin jGFeed by jQuery HowTo)
 * 
 *
 **/

(function($){

var current = null; 

$.fn.rssfeed = function(url, options) { 

    // Set pluign defaults
    var defaults = {
        limit: 10,
        header: false,
        titletag: 'h6',
        date: false,
        content: true,
        snippet: false,
        showerror: true,
        errormsg: 'View our customer testimonials <a href="http://renownestates.com/blog/category/testimonials/">here</a>',
        key: null
    };  
    var options = $.extend(defaults, options); 

    // Functions
    return this.each(function(i, e) {
        var $e = $(e);

        // Add feed class to user div
        if (!$e.hasClass('rssFeed')) $e.addClass('rssFeed');

        // Check for valid url
        if(url == null) return false;

        // Create Google Feed API address
        var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url;
        if (options.limit != null) api += "&num=" + options.limit;
        if (options.key != null) api += "&key=" + options.key;

        // Send request
        $.getJSON(api, function(data){

            // Check for error
            if (data.responseStatus == 200) {

                // Process the feeds
                _callback(e, data.responseData.feed, options);
            } else {

                // Handle error if required
                if (options.showerror)
                    if (options.errormsg != '') {
                        var msg = options.errormsg;
                    } else {
                        var msg = data.responseDetails;
                    };
                    $(e).html('<div class="rssError"><p>'+ msg +'</p></div>');
            };
        });             
    });
};

// Callback function to create HTML result
var _callback = function(e, feeds, options) {
    if (!feeds) {
        return false;
    }
    var html = '';  
    var row = 'odd';    

    // Add header if required
    if (options.header)
        html += '<div class="rssHeader">' +
            '<a href="'+feeds.link+'" title="'+ feeds.description +'">'+ feeds.title +'</a>' +
            '</div>';

    // Add body
    html += '<div class="rssBody">' +
        '<ul>';

    // Add feeds
    for (var i=0; i<feeds.entries.length; i++) {

        // Get individual feed
        var entry = feeds.entries[i];

        // Format published date
        var entryDate = new Date(entry.publishedDate);
        var pubDate = entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString();

        // Add feed row
        html += '<li class="rssRow '+row+'">' + 
            '<'+ options.titletag +'><a href="'+ entry.link +'" title="View this feed at '+ feeds.title +'">'+ entry.title +'</a></'+ options.titletag +'>'
        if (options.date) html += '<div>'+ pubDate +'</div>'
        if (options.content) {

            // Use feed snippet if available and optioned
            if (options.snippet && entry.contentSnippet != '') {
                var content = entry.contentSnippet;
            } else {
                var content = entry.content;
            }

            html += '<p>'+ content +'</p>'
        }

        html += '</li>';

        // Alternate row classes
        if (row == 'odd') {
            row = 'even';
        } else {
            row = 'odd';
        }           
    }

    html += '</ul>' +
        '</div>'

    $(e).html(html);
};
})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:09:08+00:00Added an answer on May 17, 2026 at 5:09 pm

    basically, take out the loop and use Math.random() to select an entry

    http://jsfiddle.net/Vdyb5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running tests using the TestDriven.NET VS add-in, and the class library I'm testing
Running an ASP.Net website and using TinyMCE for content management. Users need to be
Can I connect to a Ubuntu server, that is running MySQL using ADO.NET or
I have a current project running using APE that needs to work on C#/.NET...
I am using running a simple find all and paginating with willpaginate, but I'd
We are running a website using Active Server Pages & COM+ components . The
How would I quit all running user applications using Applescript?
I have an existing site in php running on Apache using the mod_rewrite plug-in.
Running a rails site right now using SQLite3. About once every 500 requests or
We are using Team City and I noticed problem during running Watin test. Sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.