Advertisement
aitormendez

Untitled

Feb 14th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2.    /*
  3.    Plugin Name: telmo timeline
  4.    Plugin URI:
  5.    Description: Recibir datos desde la REST API y construir un timelineJS
  6.    Version: 1.0
  7.    Author: Aitor
  8.    Author URI:
  9.    License: Private
  10.    */
  11. ?>
  12. <?php
  13.  
  14. // Register endpoint
  15. // -------------------
  16.  
  17. function register_things() {
  18.     register_rest_route( 'timeline/v1',
  19.     '/things/',
  20.     array(
  21.         'methods'  => WP_REST_Server::READABLE,
  22.         'callback' => 'things_that_happen',
  23.     ) );
  24. }
  25. add_action( 'rest_api_init', 'register_things' );
  26.  
  27. // add custom field
  28. // -------------------
  29.  
  30. // callback
  31. // -------------------
  32.  
  33.  
  34. function things_that_happen() {
  35.   $args = array(
  36.       'post_type' => 'post',
  37.       'posts_per_page' => -1
  38.   );
  39.   $posts = get_posts( $args );
  40.  return $posts;
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement