Return to Snippet

Revision: 42527
at March 6, 2011 10:47 by crypticsoft


Initial Code
$.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
		}
	});

Initial URL


Initial Description
* 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.

Initial Title
parse wordpress RSS feed using ajax / jquery

Initial Tags
wordpress

Initial Language
JavaScript