a4x / laravel-wordpress by a4x

A one-class package that locally caches your Wordpress posts as a Laravel collection
291
1
2
Package Data
Maintainer Username: a4x
Maintainer Contact: lionel@a440.io (Lionel Martin)
Package Create Date: 2016-03-05
Package Last Update: 2016-06-12
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:08:48
Package Statistics
Total Downloads: 291
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel-Wordpress

This library wraps your blog posts into a Laravel collection.

Installation

composer require "a4x/laravel-wordpress:0.0.1-beta"

Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:

'A440\Wordpress\WordpressServiceProvider'

Finally, you will want to publish the config using the following command:

php artisan vendor:publish --provider="A440\Wordpress\WordpressServiceProvider"

Then, update your config/wordpress.php file with your Wordpress installation URL or IP.

And you're done!

Basic Usage

<?php
namespace App\Http\Controllers;

use A440\Wordpress\Wordpress;

class HomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Wordpress $wp)
    {
        $posts = $wp->posts()
            ->sortByDesc('date')
            ->where('author.name', 'Matthew Crist')
            ->forPage(1, 4);

        dd($posts);
    }
}

Now you can access your blog posts and categories just like from an Eloquent model.