PHPackages                             wp-kit/magic-meta - 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. wp-kit/magic-meta

ActiveLibrary[Database &amp; ORM](/categories/database)

wp-kit/magic-meta
=================

A wp-kit component that handles Eloquent appending and querying of PostMeta

1.0.1(6y ago)1958↑66.7%11MITPHPPHP &gt;=7.2

Since Sep 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wp-kit/magic-meta)[ Packagist](https://packagist.org/packages/wp-kit/magic-meta)[ Docs](https://github.com/wp-kit/magic-meta)[ RSS](/packages/wp-kit-magic-meta/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (1)

wp-kit/magic-meta
=================

[](#wp-kitmagic-meta)

This is a wp-kit component that handles [`Eloquent`](https://laravel.com/docs/5.4/eloquent) appending and querying of [`PostMeta`](https://codex.wordpress.org/Post_Meta_Data_Section).

When using `Eloquent`, wouldn't it be great if we could append `PostMeta` to the Model just as Wordpress does natively? And wouldn't be great to query data based on [`meta_query`](https://codex.wordpress.org/Class_Reference/WP_Meta_Query#Accepted_Arguments) and [`tax_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) parameters? This is exactly what `wp-kit/magic-meta` handles.

Installation
------------

[](#installation)

If you're using [`Themosis`](http://framework.themosis.com/), install via [`Composer`](https://getcomposer.org/) in the root of your `Themosis` installation, otherwise install in your `Composer` driven theme folder:

```
composer require "wp-kit/magic-meta"
```

Usage
-----

[](#usage)

### Model

[](#model)

`wp-kit/magic-meta` comes with two traits, so all you need to do is include these in your model.

Based on [`drewjbartlett/wordpress-eloquent`](https://github.com/drewjbartlett/wordpress-eloquent) you can the `Post` model provided and use the `IsMagic` trait.

`wp-kit/magic-meta` relies on a `::getMeta` method on the Model to return the `meta_value`, this is exactly what `drewjbartlett/wordpress-eloquent` provides.

```
namespace Theme\Models;

use WPEloquent\Model\Post;
use WPKit\MagicMeta\Traits\IsMagic;
use WPKit\MagicMeta\Traits\TransformsQuery;

class SomePostType extends Post {

	use IsMagic;
	use TransformsQuery;

	protected $magic_meta = [
		'_some_meta_key' => 'appended_key',
		'_location' => 'location'
	];

}
```

### Query

[](#query)

***Parameters***

You can use [`::transformQuery`](https://github.com/wp-kit/magic-meta/blob/master/src/MagicMeta/Traits/MagicMeta.php#L70) [Query Scope](https://laravel.com/docs/5.4/eloquent#query-scopes) on [`Illuminate\Database\Query\Builder`](https://github.com/illuminate/database/blob/master/Query/Builder.php) to check for any of the following parameters. We also allow the query to check for any magic meta at root level of the parameters:

```
[
	's' => '',
	'meta_query' => [],
	'tax_query' => [],
	'appended_key' => 'something', // queries PostMeta key '_some_meta_key'
	'location' => 'london' // queries PostMeta key '_location'
]
```

***Using transformQuery***

```
namespace App\Controllers;

use Illuminate\Routing\Controller;
use Illuminate\Http\Request;
use App\Models\SomePostType;

class SomePostTypeController extends Controller {

	public function index(Request $request) {

		return response()->json( SomePostType::select( 'posts.*' )->type( 'some_type' )->transformQuery( $request ) );

	}

}
```

To Do
-----

[](#to-do)

- Make transformQuery agnostic to Request parameters, using Collection instead in case users are using jsonapi standard etc.

Get Involved
------------

[](#get-involved)

To learn more about how to use `wp-kit` check out the docs:

[View the Docs](https://github.com/wp-kit/theme/tree/docs/README.md)

Any help is appreciated. The project is open-source and we encourage you to participate. You can contribute to the project in multiple ways by:

- Reporting a bug issue
- Suggesting features
- Sending a pull request with code fix or feature
- Following the project on [GitHub](https://github.com/wp-kit)
- Sharing the project around your community

For details about contributing to the framework, please check the [contribution guide](https://github.com/wp-kit/theme/tree/docs/Contributing.md).

Requirements
------------

[](#requirements)

Wordpress 4+

PHP 5.6+

License
-------

[](#license)

wp-kit/magic-meta is open-sourced software licensed under the MIT License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~864 days

Total

2

Last Release

2299d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.4

1.0.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4cf98026bd84498477fafbfb9648807bf87c5ec9a0a404db2e3b7e2739cc8f9?d=identicon)[terence1990](/maintainers/terence1990)

---

Top Contributors

[![terence1990](https://avatars.githubusercontent.com/u/8171301?v=4)](https://github.com/terence1990 "terence1990 (41 commits)")

---

Tags

wordpresseloquentOOPthemosiswp-kitpostmetamagic metaassley

### Embed Badge

![Health badge](/badges/wp-kit-magic-meta/health.svg)

```
[![Health](https://phpackages.com/badges/wp-kit-magic-meta/health.svg)](https://phpackages.com/packages/wp-kit-magic-meta)
```

###  Alternatives

[dbout/wp-orm

WordPress ORM with Eloquent.

1279.6k1](/packages/dbout-wp-orm)[drewjbartlett/wordpress-eloquent

A Laravel wrapper for wordpress which turns all Wordpress models into Laravel Eloquent Models.

1521.5k](/packages/drewjbartlett-wordpress-eloquent)[tiny-pixel/acorn-db

Eloquent database support for Acorn projects

388.7k](/packages/tiny-pixel-acorn-db)

PHPackages © 2026

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