Compare commits

...

4 commits

Author SHA1 Message Date
Ben Speakman ec6e3d7263 Merge pull request #4 from WebSpanner/master
Add postId() function to get posts by id
2016-12-02 09:15:58 +00:00
Andrew Feeney a389bcea7a Add postId function to get posts by id 2016-12-02 11:07:30 +11:00
Ben Speakman 387b30fffc Merge pull request #1 from rafaelcneves/patch-2
README adjusts
2016-04-29 15:29:35 +01:00
Rafael César Neves 7f2b217bc0 README adjusts 2016-04-29 11:13:00 -03:00
2 changed files with 21 additions and 5 deletions

View file

@ -12,11 +12,7 @@ Simply add the following line to your `composer.json` and run install/update:
## Configuration ## Configuration
Publish the package config files to configure the location of your Wordpress install: You will need to add the service provider and optionally the facade alias to your `config/app.php`:
php artisan vendor:publish
You will also need to add the service provider and optionally the facade alias to your `config/app.php`:
```php ```php
'providers' => array( 'providers' => array(
@ -28,6 +24,10 @@ You will also need to add the service provider and optionally the facade alias t
), ),
``` ```
And publish the package config files to configure the location of your Wordpress install:
php artisan vendor:publish
### Usage ### Usage
The package provides a simplified interface to some of the existing api methods documented [here](http://wp-api.org/). The package provides a simplified interface to some of the existing api methods documented [here](http://wp-api.org/).
@ -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
* *