recoded/wp-query

Query Wordpress posts directly from Laravel

dev-master 2021-02-26 19:18 UTC

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.