mtv\wp\models\Post::fetch PHP Method

fetch() public method

public fetch ( )
    public function fetch()
    {
        if (empty($this->attributes['blogid']) || empty($this->attributes['id'])) {
            throw new BadMethodCallException(__("Need a blogid and post id to fetch a post", 'mtv'));
        }
        if (is_multisite() && get_current_blog_id() !== $this->blogid) {
            switch_to_blog($this->attributes['blogid']);
        }
        $post = get_post($this->attributes['id']);
        if ($post === NULL) {
            restore_current_blog();
            throw new ModelNotFound("Post", __("Post not found", 'mtv'));
        }
        $this->reload($post);
        if (is_multisite() && get_current_blog_id() !== $this->blogid) {
            restore_current_blog();
        }
    }