1. Go to this page and download the library: Download tradzero/wp_rest_laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tradzero / wp_rest_laravel example snippets
'providers' => [
// Other service providers...
Tradzero\WPREST\WPRESTServiceProvider::class,
],
use Tradzero\WPREST\Resources\Post;
use Tradzero\WPREST\Resources\Category;
use WPREST;
$post = new Post();
$post->setTitle('hello world');
$post->setContent('Its post created using WP REST API');
WPREST::createPost($post);
$post->setId('XX');
WPREST::updatePost($post);
$category = new Category;
$category->setName('category 1');
WPREST::findCategoryOrCreate($category);
// or
WPREST::createCategory($category);
$post->setCategories(array($category));
WPREST::createPost($post);