labchain/laravel-wp-api

Modified Laravel package for the Wordpress JSON REST API

dev-master 2019-07-18 18:45 UTC

This package is auto-updated.

Last update: 2024-04-19 06:35:19 UTC


README

Laravel 5 package for the Wordpress JSON REST API

Install

Simply add the following line to your composer.json and run install/update:

"Labchain/laravel-wp-api": "~1.0"

Configuration

You will need to add the service provider and optionally the facade alias to your config/app.php:

'providers' => array(
  Labchain\LaravelWpApi\LaravelWpApiServiceProvider::class
)

'aliases' => array(
  'WpApi' => Labchain\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. You can either use the Facade provided or inject the Labchain\LaravelWpApi\WpApi class.

Posts

WpApi::posts($page);

Pages

WpApi::pages($page);

Post

WpApi::post($slug);
WpApi::postId($id);

Categories

WpApi::getCategories();

Tags

WpApi::tags();

Category posts

WpApi::getCategories($id);

Author posts

WpApi::authorPosts($id);

Tag posts

WpApi::tagPosts($slug, $page);

Search

WpApi::search($post);

Archive

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