recoded / wp-query
Query Wordpress posts directly from Laravel
dev-master
2021-02-26 19:18 UTC
Requires
- php: ^7.4
- ext-json: *
- guzzlehttp/guzzle: ^6.5
- laravel/framework: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
This package is auto-updated.
Last update: 2024-09-27 03:14:41 UTC
README
wp-query is a simple way to query data from Wordpress in Laravel
Installation
To install all you need to do is:
composer require recoded/wp-query
Usage
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.