Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: telmo timeline
- Plugin URI:
- Description: Recibir datos desde la REST API y construir un timelineJS
- Version: 1.0
- Author: Aitor
- Author URI:
- License: Private
- */
- ?>
- <?php
- // Register endpoint
- // -------------------
- function register_things() {
- register_rest_route( 'timeline/v1',
- '/things/',
- array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => 'things_that_happen',
- ) );
- }
- add_action( 'rest_api_init', 'register_things' );
- // add custom field
- // -------------------
- // callback
- // -------------------
- function things_that_happen() {
- $args = array(
- 'post_type' => 'post',
- 'posts_per_page' => -1
- );
- $posts = get_posts( $args );
- return $posts;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement