Skip to content

Instantly share code, notes, and snippets.

@rainbat
Last active September 19, 2018 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainbat/1243d752b85f5c0fc8c92edcfd5773e8 to your computer and use it in GitHub Desktop.
Save rainbat/1243d752b85f5c0fc8c92edcfd5773e8 to your computer and use it in GitHub Desktop.
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