An open API service indexing awesome lists of open source software.

https://github.com/benrutlandweb/wpeloquent

Eloquent models for WordPress
https://github.com/benrutlandweb/wpeloquent

eloquent wordpress

Last synced: about 1 month ago
JSON representation

Eloquent models for WordPress

Awesome Lists containing this project

README

        

# WPEloquent

Eloquent models for WordPress

## Introduction

WPEloquent uses Laravel's [Eloquent ORM](https://laravel.com/docs/8.x/eloquent)
to interact with WordPress' database.

WPEloquent comes with the following Models:

- Post
- Page
- Attachment
- PostMeta
- Term
- TermMeta
- User
- UserMeta
- Comment
- CommentMeta
- Option
- Taxonomy
- TermRelationship

---

## Getting started

Install the brw/wp-eloquent package

```bash
composer require brw/wp-eloquent
```

_functions.php_

```php
'mysql',
'prefix' => 'wp_',
'host' => DB_HOST,
'database' => DB_NAME,
'username' => DB_USER,
'password' => DB_PASSWORD,
'port' => '3306',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
]
);
```

## The basics

Each model has relationships defined to interact with other models. As an
example, the Post model has terms, author, comments and so on.

Full documentation on the Fluent API: [Eloquent ORM](https://laravel.com/docs/8.x/eloquent).

```php
where('post_status', 'publish')->get();

foreach ($posts as $post) : ?>

title; ?>


author->email; ?>