Skip to content

Instantly share code, notes, and snippets.

@blobaugh
Created February 14, 2015 19:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blobaugh/f60fb50838edabd49159 to your computer and use it in GitHub Desktop.
Save blobaugh/f60fb50838edabd49159 to your computer and use it in GitHub Desktop.
WCMaui Code Demo
add_filter( 'the_content', function( $content ) {
$response = wp_remote_get( 'http://ben.lobaugh.net/wp-json/posts' );
if( '200' == wp_remote_retrieve_response_code( $response ) ) {
$posts = json_decode( wp_remote_retrieve_body( $response ) );
foreach( $posts AS $p ) {
echo $p->title->rendered . "<br/>";
}
} else {
echo "Something bad happened";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment