Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created June 17, 2014 00:10
Show Gist options
  • Save whyisjake/38f0214b7a956d7fdebb to your computer and use it in GitHub Desktop.
Save whyisjake/38f0214b7a956d7fdebb to your computer and use it in GitHub Desktop.
A Pen by Jake Spurlock.
<article>
</article>
jQuery( document ).ready( function( $ ) {
// Grab the URL for all of the posts from Make:
// https://public-api.wordpress.com/rest/v1/sites/makezine.com/posts/?tag=white-house-maker-faire
posts_url = 'https://public-api.wordpress.com/rest/v1/sites/makezine.com/posts/?tag=white-house-maker-faire';
$.getJSON( posts_url, function( posts ) {
the_posts = posts.posts;
console.log( the_posts );
output = '<div class="row">';
$.each( $( the_posts ), function( i, post ){
output += '<div class="span3">';
output += '<img class="thumbnail" src="' + post.featured_image + '?w=220&h=160&crop=1">';
output += '<h3>' + post.title + '</h3>';
if ( i % 4 ) {
output += '</div></div><div class="row">';
} else {
output += '</div>';
}
});
output += '</div>';
console.log( output );
$( 'article' ).html( output );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment