Skip to content

Instantly share code, notes, and snippets.

@joecue
Last active June 10, 2016 15:11
Show Gist options
  • Save joecue/e2f232825a605c1b2a2a to your computer and use it in GitHub Desktop.
Save joecue/e2f232825a605c1b2a2a to your computer and use it in GitHub Desktop.
JSON Example for Retrieving Media Post Data from WP-API
<!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://mysite.dev/mylccc/wp-json/wp/v2/media/5", function(data) {
var div = $('<div style="border: 1px solid #9f9f9f; min-height: 15px;"/>');
div.append( $('<p />') );
$(div).attr('id', data.id);
$('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