Skip to content

Instantly share code, notes, and snippets.

@rainbat

rainbat/loop-posts.html Secret

Last active Sep 19, 2018
Embed
What would you like to do?
Wordpress loop Posts using jQuery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>Show Adds via JSON Rest Query</h1>
<script>
(function($) {
$(document).ready(function(){
$.getJSON("https://www.rainbat.ch/wp-json/wp/v2/inserat/?json=1",function(data) {
console.log(data);
$.each(data, function(k, v) {
$('body').append( '<h3>' + v.title.rendered + '</h3>' );
$('body').append( '<p>' + v.content.rendered + '</p>' );
});
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.