Forked from Secret Sam's Pen Jotfe.
A Pen by Jake Spurlock on CodePen.
Forked from Secret Sam's Pen Jotfe.
A Pen by Jake Spurlock on CodePen.
| <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 ); | |
| }); | |
| }); |