Advertisement
brucewhealton

Get Poets list from Wordpress json-api

Apr 30th, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function listPoets(data) {
  2.     var output='';
  3.     var val = '';
  4.     $.each(data.posts,function(key,val) {
  5.         console.log(val.thumbnail);
  6.         output += '<div data-role="collapsible">';
  7.         output += '<h3>' + val.title + '</h3>';
  8.         if (val.thumbnail !== 'undefined') {
  9.         output += '<img src="' + val.thumbnail + '" alt="' + val.title + '"/>';
  10.         } else {
  11.         output += '<img src="images/WSLogo.jpg" alt="Word Salad Logo"/>';
  12.         }
  13.         output += val.content;
  14.         output += '</div>';
  15.     }); // go through each post
  16.     $('#poetslist').html( $(output) );
  17. } // lists all the poems
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement