PHPackages                             themeszone/wp-orm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. themeszone/wp-orm

ActiveWordpress-plugin-helper[Database &amp; ORM](/categories/database)

themeszone/wp-orm
=================

ORM using eloquent for wordpress plugin

1.0.0(6y ago)1111GPL-3.0-or-laterPHPPHP &gt;=7.0

Since Mar 25Pushed 6y agoCompare

[ Source](https://github.com/themeszone/wp-eloquent-orm)[ Packagist](https://packagist.org/packages/themeszone/wp-orm)[ RSS](/packages/themeszone-wp-orm/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

wp-eloquent-orm
===============

[](#wp-eloquent-orm)

ORM using Eloquent for wordpress

Usage example
-------------

[](#usage-example)

Included models are

- Post : Wordpress posts with post\_type = post
- Page : Wordpress posts with post\_type = page
- Cpt : Wordpress posts with passed type filter
- PostMeta : Model for Wordpress postmeta table
- User : Model for Wordpress users table
- UserMeta : Model for Wordpress usermeta table
- Comments : Model for Wordpress comments table

Get all the pages and print its title

```
$pages = Page::all();

foreach($pages as $page) {

  var_dump($page->ID, $page->post_title);
}

Do not forget to include the use statement
use XS\ORM\Model\Page;
use XS\ORM\Model\Post;
...

```

```
// Get all the page with its comment
$pages = Page::with('comments')->get();

foreach($pages as $page) {
    foreach($page->comments as $comment) {
        var_dump($comment->comment_content);
    }
}

// Get all the page with its comments and meta's and titles includes the word "Sample"

$pages = Page::with('comments')->with('meta')->where('post_title', 'LIKE', '%Sample%')->get();

foreach($pages as $page) {
    foreach($page->comments as $comment) {
        var_dump($comment->comment_content);
    }

    foreach($page->meta as $item) {
        var_dump($item->meta_key, $item->meta_value);
    }
}

// Reading a specific post by its id
$post = Post::find(24);

// filter all the post by author and status and also at least one comment and order by ID
$posts = Post::status('publish')->author(5)->where('comment_count', '>=', 1)->orderBy('ID')->get();

```

*Cpt model points to the wordpress posts table but it does not auto filter any type, with this mode any type can be filtered. some examples -*

```
// Get all the published posts
$posts = Cpt::post()->status('publish')->get();

// Get all the page with title having 'Sample' word
$posts = Cpt::page()->where('post_title', 'LIKE', '%Sample%')->get();

// Get all the page of a custom post type with its meta and comments -
$posts = Cpt::type('xs-skeleton-plg')->with('meta')->with('comments')->get();

```

*You can query Post meta table directly too -*

```
// Get all the meta of post id 2
$pm = PostMeta::where('post_id', 2)->get(); OR
$pm = PostMeta::post(2)->get();

// Get all the meta of post id 2 and meta_key = _wp_page_template
$pm = PostMeta::post(2)->key('_wp_page_template')->get();

// If you want to return only the first row then -
$pm = PostMeta::post(2)->first();
$pm = PostMeta::post(2)->key('_wp_page_template')->first();

```

Creating a Model for your custom table
--------------------------------------

[](#creating-a-model-for-your-custom-table)

```
use XS\ORM\Model\XS_Model;

class Player extends XS_Model {

    //protected $table = 'my_player';

}

```

Eloquent by default takes the table name as plural form of Model name, in this case it will point to *players* table and primary key as id column. If your table has different name then just `protected $table = 'table_name'` property in the model. And if primary key is not `id` then add `protected $primaryKey = 'id';` property in the model.

```
// Get all players
Player::all();
// Find player by primary key value -
Player::find(5);
// Count total active player
Player::where('active', 1)->count();
// Find highest income of active players ;
Player::where('active', 1)->max('income');

```

### Still need to run some raw query?

[](#still-need-to-run-some-raw-query)

```
$player = DB::table('players')->where('name', 'John')->first();
echo $user->name;

$players = DB::table('players')->select('name', 'email as player_email')->get();

$players = DB::select('select * from players where active = ?', [1]);
$players = DB::select('select * from players where id = :id', ['id' => 1]);

DB::insert('insert into players (id, name) values (?, ?)', [1, 'Dayle']);
$affected = DB::update('update players set goal = 10 where name = ?', ['John']);
$deleted = DB::delete('delete from players');

DB::statement('drop table players');

DB::transaction(function () {
    DB::table('players')->update(['votes' => 1]);

    DB::table('posts')->delete();
});

$title = DB::table('roles')->pluck('title');
$roles = DB::table('roles')->pluck('title', 'name');
$price = DB::table('orders')->where('finalized', 1)->avg('price');

$users = DB::table('users')
                     ->select(DB::raw('count(*) as user_count, status'))
                     ->where('status', '', 1)
                     ->groupBy('status')
                     ->get();

$orders = DB::table('orders')
                ->select('department', DB::raw('SUM(price) as total_sales'))
                ->groupBy('department')
                ->havingRaw('SUM(price) > 2500')
                ->get();

//Need Join ?
$users = DB::table('users')
            ->leftJoin('posts', 'users.id', '=', 'posts.user_id')
            ->get();

$users = DB::table('sizes')
            ->crossJoin('colours')
            ->get();

$users = DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')
            ->join('orders', 'users.id', '=', 'orders.user_id')
            ->select('users.*', 'contacts.phone', 'orders.price')
            ->get();

```

How it Works
------------

[](#how-it-works)

- Eloquent is mainly used here as the query builder
- WPDB is used to run queries built by Eloquent
- It doesn't create any extra MySQL connection

For more possibility check  &amp;

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

8

Last Release

2239d ago

Major Versions

0.2.5 → 1.0.02020-03-31

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1304131?v=4)[Themes Zone](/maintainers/themeszone)[@themeszone](https://github.com/themeszone)

---

Top Contributors

[![atiqsu](https://avatars.githubusercontent.com/u/7007821?v=4)](https://github.com/atiqsu "atiqsu (14 commits)")[![themeszone](https://avatars.githubusercontent.com/u/1304131?v=4)](https://github.com/themeszone "themeszone (6 commits)")[![atiq-xs](https://avatars.githubusercontent.com/u/61375078?v=4)](https://github.com/atiq-xs "atiq-xs (1 commits)")

### Embed Badge

![Health badge](/badges/themeszone-wp-orm/health.svg)

```
[![Health](https://phpackages.com/badges/themeszone-wp-orm/health.svg)](https://phpackages.com/packages/themeszone-wp-orm)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)[sleimanx2/plastic

Plastic is an Elasticsearch ODM and mapper for Laravel. It renders the developer experience more enjoyable while using Elasticsearch by providing a fluent syntax for mapping , querying and storing eloquent models.

508141.9k1](/packages/sleimanx2-plastic)[ntanduy/cloudflare-d1-database

Easy configuration and setup for D1 Database connections in Laravel.

215.4k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
