/ Published in: JavaScript
* Set your local path to the wordpress install, in my case was: "/blog/feed"
* Edit the var contain = make it set to the selector, in my case I'm populated a list tag <ul></ul>.
* Edit the var limit = 5; Set the amount of blog posts you want to display.
* Edit the var contain = make it set to the selector, in my case I'm populated a list tag <ul></ul>.
* Edit the var limit = 5; Set the amount of blog posts you want to display.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.ajax({ type: "GET", url: "/blog/feed", dataType: "xml", success: function(xml) { var contain = $("div.panel ul"); var limit = 5; $(xml).find('item').each(function(index){ if( index < limit ){ var title = $(this).find('title').text(); var url = $(this).find('link').text(); var pubDate = $(this).find('pubDate').text(); $('<li></li>').html('<a href="'+url+'">'+title+'</a>').appendTo(contain); return; } });//end each } });