PHPackages                             barnythorpe/wp-fluent-queries - 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. barnythorpe/wp-fluent-queries

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

barnythorpe/wp-fluent-queries
=============================

A fluent interface for constructing Wordpress queries in a safe, readable and clean manner.

0.1.0(12mo ago)03MITPHPCI passing

Since May 11Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Barny-Thorpe/wp-fluent-queries)[ Packagist](https://packagist.org/packages/barnythorpe/wp-fluent-queries)[ RSS](/packages/barnythorpe-wp-fluent-queries/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

WP Fluent Queries
=================

[](#wp-fluent-queries)

Note

This package has been moved into:

[![Latest Version](https://camo.githubusercontent.com/c533c0515d92d17e3d118d7d58bddc5ee6cd9eca3b7e4b2dc8c378dc797f073a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261726e7974686f7270652f77702d666c75656e742d71756572696573)](https://packagist.org/packages/barnythorpe/wp-fluent-queries) [![Passing Tests](https://camo.githubusercontent.com/0e0cc970c861864f03ac2a75e56341f202f0556bd5880a778ed934255449d94a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4261726e792d54686f7270652f77702d666c75656e742d717565726965732f7068702d63692e796d6c)](https://github.com/Barny-Thorpe/wp-fluent-queries/actions/workflows/php-ci.yml) [![Packagist Licence](https://camo.githubusercontent.com/af65eb756ef5cbeec93fbf43adbb6f99781942421818cdd212695aca0bef1f1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6261726e7974686f7270652f77702d666c75656e742d71756572696573)](https://packagist.org/packages/barnythorpe/wp-fluent-queries) [![Last Commit](https://camo.githubusercontent.com/bd3b926262511818e131c087ac839328b2fb1596bfee82847982b05a76191766/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f4261726e792d54686f7270652f77702d666c75656e742d71756572696573)](https://github.com/Barny-Thorpe/wp-fluent-queries/commits/main/)

This package aims to create a fluent interface for constructing Wordpress queries in a safe, readable and clean manner.

🔧 Installation
--------------

[](#-installation)

```
composer require barnythorpe/wp-fluent-queries
```

🛠 Usage
-------

[](#-usage)

### Main Query Builders

[](#main-query-builders)

The package provides query builders for the following:

- WP\_Query - [https://developer.wordpress.org/reference/classes/wp\_query/](https://developer.wordpress.org/reference/classes/wp_query/)
- WP\_Term\_Query - [https://developer.wordpress.org/reference/classes/wp\_term\_query/](https://developer.wordpress.org/reference/classes/wp_term_query/)
- WP\_User\_Query - [https://developer.wordpress.org/reference/classes/wp\_user\_query/](https://developer.wordpress.org/reference/classes/wp_user_query/)

The queries are constructed like so:

```
$builder = new PostQueryBuilder();
$builder
    ->postType('custom_post_type')
    ->postsPerPage(12)
    ->fields('ids');
```

or to make life simpler using the factory class:

```
$query = Query::post()
    ->postType('custom_post_type')
    ->postsPerPage(12)
    ->fields('ids');
```

### Nesting Conditions

[](#nesting-conditions)

The package also provides a solution for the complex nested queries within the main wordpress queries:

- WP\_Meta\_Query - [https://developer.wordpress.org/reference/classes/wp\_meta\_query/](https://developer.wordpress.org/reference/classes/wp_meta_query/)
- WP\_Tax\_Query - [https://developer.wordpress.org/reference/classes/wp\_tax\_query/](https://developer.wordpress.org/reference/classes/wp_tax_query/)
- WP\_Date\_Query - [https://developer.wordpress.org/reference/classes/wp\_date\_query/](https://developer.wordpress.org/reference/classes/wp_date_query/)

These can be constructed using the group and condition classes and added to the main query like so:

```
$wp_query = Query::post()
    ->postType('custom_post_type')
    ->taxQuery(QueryGroups::tax(
        QueryConditions::tax()->taxonomy('example_tax')->terms([1, 2, 3])->field('term_id'),
        QueryConditions::tax()->taxonomy('another_tax')->terms([4, 5, 6])->field('term_id'),
    ))
    ->metaQuery(QueryGroups::meta(
        QueryConditions::meta()->compare('=')->type('CHAR')->key('foo')->value('bar'),
        QueryConditions::meta()->compare('!=')->type('CHAR')->key('baz')->value('qux'),
    ));
```

Please go to the Groups and Conditions tests for more examples:

- [Groups](tests/Unit/GroupsTest.php)
- [Conditions](tests/Unit/ConditionsTest.php)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance55

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

363d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a6b3057482ba84ac7b0b84218f21eef79a5519dac9525a4ecdfd8745819930a?d=identicon)[barnythorpe](/maintainers/barnythorpe)

---

Top Contributors

[![Barny-Thorpe](https://avatars.githubusercontent.com/u/47748897?v=4)](https://github.com/Barny-Thorpe "Barny-Thorpe (7 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/barnythorpe-wp-fluent-queries/health.svg)

```
[![Health](https://phpackages.com/badges/barnythorpe-wp-fluent-queries/health.svg)](https://phpackages.com/packages/barnythorpe-wp-fluent-queries)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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