Skip to content

Instantly share code, notes, and snippets.

@joecue
Created May 19, 2015 20:53
Show Gist options
  • Save joecue/13bc28206dea0e47539f to your computer and use it in GitHub Desktop.
Save joecue/13bc28206dea0e47539f to your computer and use it in GitHub Desktop.
Sample JSON File Reading WP API Call
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
//$.getJSON("http://wordpress/wp-json/wp/v2/posts", function (data) {
$.getJSON("http://wordpress/wp-json/posts/1", function (data) {
var div = $('<div />');
div.append( $('<h1 />', {text: data.title}) );
div.append( $(data.content) );
$('body').append(div);
});
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment