August 2017
Beginner
412 pages
10h 30m
English
You've already learned how to create basic WordPress plugins in this very chapter, so now, let's combine this knowledge with the new addition of REST API. The plugin we're building is going to simply display a list of posts from another blog based on a shortcode.
Let's have a look at the full code of this plugin--all within a single file named kk_rest_demo.php:
function kk_rest_handler($atts, $content=null) {
extract(shortcode_atts(array(
'website_domain' => 'newinternetorder.com',
'how_many' => '3'
), $atts));
$response = wp_remote_get( 'http://' . $website_domain . '/wp- json/wp/v2/posts/' ); if( is_wp_error( $response ) ) { $error_string = $response->get_error_message(); return 'Error occurred: <em>' ...Read now
Unlock full access