Add postId function to get posts by id
This commit is contained in:
parent
387b30fffc
commit
a389bcea7a
|
|
@ -51,6 +51,11 @@ WpApi::post($slug);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```php
|
||||||
|
WpApi::postId($id);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
#### Categories
|
#### Categories
|
||||||
```php
|
```php
|
||||||
WpApi::categories();
|
WpApi::categories();
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue