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:
- A div, span, or other element with a selector, ie id or class within the HTML
- Including the file jquery.rss.js in your head section
- 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.