wp-query is a simple way to query data from Wordpress in Laravel
To install all you need to do is:
composer require recoded/wp-query
You can display a post very simply like this:
<?php
use Illuminate\Support\Facades\Route;
use Recoded\WpQuery\Database\Models\Post;
Route::get('post/{post}', function (Post $post) {
return $post;
});
The default Post model has the following relations which you can query (and eagerload):
- author (User)
- categories (Category)
- featuredMedia (Media)
- replies (Comment)
The default Comment model also has a children relationship. This contains all comments that have the current comment as parent.