WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin : Json Api] Force include fields (1 post)

  1. Killwil
    Member
    Posted 2 years ago #

    Hello,

    For some reasons I want to force include fields and bypass the include querystring.
    I code a specific controller for this.

    My code is here

    class JSON_API_Specific_Controller {
    
        public function get_Specific() {
    
    // force include        $_REQUEST['include']='id,type,url,title,excerpt,comment_count,thumbnail,custom_fields';
    
    // force post_type
            $_REQUEST['post_type']='SpecificPostType';
    
            global $json_api;
    
            $todaysDate = date('Ymd H:i');
    
            $posts = $json_api->introspector->get_posts(array(
    
                'meta_query' => array(
                    array(
                        'key' => 'EndsOn',
                        'value' => $todaysDate,
                        'compare' => '>='
                    ),
                    array(
                        'key' => 'StartsOn',
                        'value' => $todaysDate,
                        'compare' => '<'
                    )
                ),
                'orderby' => 'meta_value',
                'meta_key' => 'EndsOn',
                'order' => 'ASC'
    
            ));
    
            return array('posts' => $posts);
        }
    
    }

    The filter of SpecificPostType work well and I retrieve only "SpecificPostType".
    The Include filter doesn't seems to work and I retrieve all fields, and I don't know why ?
    Is someone could help me on this issue ?
    Thanks a lot

Topic Closed

This topic has been closed to new replies.

About this Topic