mardi 31 mai 2016

access all-in-one-event-calendar functions outside if wordpress

All i am trying to create rest-api and i have successful at retrieving all other posts form WP using this
Calling WP functions outside of functions.php

Now i try same code to access all events using below code and it return me null.

function get_events($body) {
        return json_encode($ai1ec_registry);
//        global $ai1ec_calendar_helper, $ai1ec_events_helper;
        global $ai1ec_registry;
//        global $post;
//        return json_encode($ai1ec_registry);
        $events = new WP_Query('post_type=ai1ec_event');
        $returnevent = [];
        while ($events->have_posts()):
            $events->the_post();
            $event = new Ai1ec_Event($ai1ec_registry);
            $event->initialize_from_id($post->ID);
            $event_name = $event->get('post')->post_name;
//            $returnevent[] = $event_name;
            return $event_name;

//            return json_encode($event_name);
        endwhile;
//        return json_encode($returnevent);
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire