Merge pull request #4 from WebSpanner/master

Add postId() function to get posts by id
This commit is contained in:
Ben Speakman 2016-12-02 09:15:58 +00:00 committed by GitHub
commit ec6e3d7263
2 changed files with 16 additions and 0 deletions

View file

@ -51,6 +51,11 @@ WpApi::post($slug);
``` ```
```php
WpApi::postId($id);
```
#### Categories #### Categories
```php ```php
WpApi::categories(); WpApi::categories();

View file

@ -60,6 +60,17 @@ class WpApi
return $this->get('posts', ['type' => 'page', 'page' => $page]); return $this->get('posts', ['type' => 'page', 'page' => $page]);
} }
/**
* Get post by id
*
* @param int $id
* @return array
*/
public function postId($id)
{
return $this->get("posts/$id");
}
/** /**
* Get post by slug * Get post by slug
* *