• Skip to main content
  • What We Do
  • Our Work
  • Contact

Mackey

RSS via jQuery/ JSON – Stupid Simple

May 9, 2014 by Mackey

RSS via jQuery/ JSON – Stupid Simple

So we needed to pull the most recent article from WordPress into a Shopify setup.  Because of Shopify I could not use a server side script, ie PHP and needed to find an alternative.  And bam, jQuery.

Here is the link to the files on GitHub: https://github.com/sdepold/jquery-rss

 

And here is a little JSFiddle: https://jsfiddle.net/jhfrench/AFHfn/

 

Essentially all that is need is needed is:

  1. A div, span, or other element with a selector, ie id or class within the HTML
  2. Including the file jquery.rss.js in your head section
  3. And then running scripts such as the following:

$(“#rss-default”).rss(“https://mrlabs.me/kayu/feed/”).show();

$(“#rss-styled”).rss(“https://mrlabs.me/kayu/feed/”, {
limit: 1,
layoutTemplate: ‘<dl class=”dl-horizontal”>{entries}</dl>’,
entryTemplate: ‘<dt><a href=”{url}”>{title}</a></dt>’
}).show();

$(“#rss-metro”).rss(“https://www.recruiter.com/feed/career.xml”, {
limit: 4,
layoutTemplate: ‘<span id=”entries”>{entries}</span>’,
entryTemplate: ‘<a href=”{url}”>{title}</a>|’
}).show();

This all utilizes the wonder of Google Feed API. Super cool.

Filed Under: Snippets (of code that is)

Mackey Creative Lab
Web Design and Development, Branding, Graphic Design and Marketing Strategy
680 East Colorado Blvd., Suite 180 & Second Floor, Pasadena, CA 91101
info@mackeycreativelab.com // 626 214 5093
© 2014-2021 Mackey, LLC, All Rights Reserved

Want to join the Lab? Become a lab partner

Need Wordpress Performance & Security Management? Learn More