From a389bcea7a21b1db0b6261faa8e9898ecf804fc1 Mon Sep 17 00:00:00 2001 From: Andrew Feeney Date: Fri, 2 Dec 2016 11:07:30 +1100 Subject: [PATCH] Add postId function to get posts by id --- README.md | 5 +++++ src/Threesquared/LaravelWpApi/WpApi.php | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 6a0106d..6db6c63 100755 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ WpApi::post($slug); ``` +```php +WpApi::postId($id); + +``` + #### Categories ```php WpApi::categories(); diff --git a/src/Threesquared/LaravelWpApi/WpApi.php b/src/Threesquared/LaravelWpApi/WpApi.php index cdaa158..74971dc 100755 --- a/src/Threesquared/LaravelWpApi/WpApi.php +++ b/src/Threesquared/LaravelWpApi/WpApi.php @@ -60,6 +60,17 @@ class WpApi 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 *