Created
December 4, 2015 15:39
-
-
Save robertdevore/7730c98cfc1a2568736c to your computer and use it in GitHub Desktop.
jQuery code to display recent posts from the WordPress API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$.get( "wp-json/wp/v2/posts", function( data ) { | |
$.each( data, function( i, val ) { | |
$( "#app" ).append( | |
'<li>' + | |
'<h3>' + | |
val.title.rendered + | |
'</h3>' + | |
'<p>' + | |
val.excerpt.rendered + | |
'</p>' + | |
'</li>' | |
); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment