EP_API::get_post PHP Method

get_post() public method

Get a post from the index
Since: 0.9.0
public get_post ( integer $post_id ) : boolean
$post_id integer
return boolean
    public function get_post($post_id)
    {
        $index = ep_get_index_name();
        $path = $index . '/post/' . $post_id;
        $request_args = array('method' => 'GET');
        $request = ep_remote_request($path, apply_filters('ep_get_post_request_args', $request_args, $post_id));
        if (!is_wp_error($request)) {
            $response_body = wp_remote_retrieve_body($request);
            $response = json_decode($response_body, true);
            if (!empty($response['exists']) || !empty($response['found'])) {
                return $response['_source'];
            }
        }
        return false;
    }