Skip to content
This repository was archived by the owner on Sep 27, 2025. It is now read-only.

Latest commit

 

History

History
29 lines (23 loc) · 702 Bytes

File metadata and controls

29 lines (23 loc) · 702 Bytes

WP Query

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.