Created
May 19, 2015 20:53
-
-
Save joecue/13bc28206dea0e47539f to your computer and use it in GitHub Desktop.
Sample JSON File Reading WP API Call
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
<!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