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
- Host: GitHub
- URL: https://github.com/benrutlandweb/wpeloquent
- Owner: BenRutlandWeb
- License: mit
- Created: 2020-09-07T17:17:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-22T18:59:15.000Z (almost 6 years ago)
- Last Synced: 2025-03-27T15:48:08.675Z (over 1 year ago)
- Topics: eloquent, wordpress
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
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; ?>