PHP code example of a4x / laravel-wordpress

1. Go to this page and download the library: Download a4x/laravel-wordpress 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/ */

    

a4x / laravel-wordpress example snippets


'A440\Wordpress\WordpressServiceProvider'


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);
    }
}
bash
php artisan vendor:publish --provider="A440\Wordpress\WordpressServiceProvider"