https://github.com/threesquared/laravel-wp-api
Laravel package for the Wordpress JSON REST API
https://github.com/threesquared/laravel-wp-api
laravel laravel-5-package wordpress wp-api
Last synced: 21 days ago
JSON representation
Laravel package for the Wordpress JSON REST API
- Host: GitHub
- URL: https://github.com/threesquared/laravel-wp-api
- Owner: threesquared
- License: mit
- Fork: true (Cyber-Duck/laravel-wp-api)
- Created: 2015-11-30T16:29:45.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T20:33:28.000Z (over 5 years ago)
- Last Synced: 2025-11-27T16:37:12.047Z (2 months ago)
- Topics: laravel, laravel-5-package, wordpress, wp-api
- Language: PHP
- Size: 17.6 KB
- Stars: 13
- Watchers: 7
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-wp-api
[](https://travis-ci.org/threesquared/laravel-wp-api) [](https://packagist.org/packages/threesquared/laravel-wp-api)
Laravel 5 package for the [Wordpress JSON REST API](https://github.com/WP-API/WP-API)
## Install
Simply add the following line to your `composer.json` and run install/update:
"threesquared/laravel-wp-api": "~2.0"
## Configuration
You will need to add the service provider and optionally the facade alias to your `config/app.php`:
```php
'providers' => array(
Threesquared\LaravelWpApi\LaravelWpApiServiceProvider::class
)
'aliases' => array(
'WpApi' => Threesquared\LaravelWpApi\Facades\WpApi::class
),
```
And publish the package config files to configure the location of your Wordpress install:
php artisan vendor:publish
### Usage
The package provides a simplified interface to some of the existing api methods documented [here](http://wp-api.org/).
You can either use the Facade provided or inject the `Threesquared\LaravelWpApi\WpApi` class.
#### Posts
```php
WpApi::posts($page);
```
#### Pages
```php
WpApi::pages($page);
```
#### Post
```php
WpApi::post($slug);
```
```php
WpApi::postId($id);
```
#### Categories
```php
WpApi::categories();
```
#### Tags
```php
WpApi::tags();
```
#### Category posts
```php
WpApi::categoryPosts($slug, $page);
```
#### Author posts
```php
WpApi::authorPosts($slug, $page);
```
#### Tag posts
```php
WpApi::tagPosts($slug, $page);
```
#### Search
```php
WpApi::search($query, $page);
```
#### Archive
```php
WpApi::archive($year, $month, $page);
```