Posted By

crypticsoft on 03/06/11


Tagged

rss wordpress


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

henji4
acousins
adambundy


parse wordpress RSS feed using ajax / jquery


 / 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
      .
    • Edit the var limit = 5; Set the amount of blog posts you want to display.
    1. $.ajax({
    2. type: "GET",
    3. url: "/blog/feed",
    4. dataType: "xml",
    5. success: function(xml) {
    6.  
    7. var contain = $("div.panel ul");
    8. var limit = 5;
    9.  
    10. $(xml).find('item').each(function(index){
    11. if( index < limit ){
    12. var title = $(this).find('title').text();
    13. var url = $(this).find('link').text();
    14. var pubDate = $(this).find('pubDate').text();
    15. $('<li></li>').html('<a href="'+url+'">'+title+'</a>').appendTo(contain);
    16. return;
    17. }
    18.  
    19. });//end each
    20. }
    21. });

    Report this snippet  

    You need to login to post a comment.