ejimba/laravel-wp-api

Laravel package for the Wordpress JSON REST API

0.1.0 2015-05-17 11:32 UTC

This package is auto-updated.

Last update: 2021-09-28 16:21:50 UTC


README

This is a fork of https://github.com/Cyber-Duck/laravel-wp-api. All credits go to Cyber-Duck. This is a Laravel 4.2 package for the Wordpress JSON REST API

Install

This is a Laravel 4.2 package. Laravel 5 users should use this Simply add the following line to your composer.json and run composer update:

"ejimba/laravel-wp-api": "0.1.x"

Add

'Ejimba\LaravelWpApi\LaravelWpApiServiceProvider',

to the providers array in your app/config/app.php:

Configuration

Publish the package config files to configure the location of your Wordpress install:

php artisan config:publish ejimba/laravel-wp-api

Ensure you update the endpoint to match your wordpress site e.g.

return array(

    'endpoint' => 'http://www.mywordpresssite.com',
    
);

On the target site, ensure you install the Wordpress JSON API Plugin. You search it from the plugins menu in the worpress dashboard.

Usage

The package provides a simplified interface to some of the existing api methods documented here. You can either use the Facade provided or inject the LaravelWpApi class.

Posts

All Posts
LaravelWpApi::posts();
Posts in page
LaravelWpApi::posts($page);
Single Post
LaravelWpApi::post($slug);

Pages

LaravelWpApi::pages();

Categories

LaravelWpApi::categories();

Tags

LaravelWpApi::tags();

Category posts

LaravelWpApi::category_posts($slug, $page);

Search

LaravelWpApi::search($query, $page);

Archive

LaravelWpApi::archive($year, $month, $page);

Support

In case of any issue please test with a new laravel installation. If it persists, file an issue and I will try my best to help you out.

Credits

  1. Cyber-Duck
  2. Laravel

License

Licensed under The MIT License (MIT).