PHPackages                             expedition/wpqb - 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. expedition/wpqb

ActivePlugin

expedition/wpqb
===============

Build queries with an elegant WordPress-oriented query builder

130[1 PRs](https://github.com/bitfactory-nl/wpqb/pulls)PHP

Since Dec 1Pushed 1y ago2 watchersCompare

[ Source](https://github.com/bitfactory-nl/wpqb)[ Packagist](https://packagist.org/packages/expedition/wpqb)[ RSS](/packages/expedition-wpqb/feed)WikiDiscussions version/1.x Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

WPQB
====

[](#wpqb)

A flexible and powerful query builder tailored for WordPress, making complex database queries simple.

[![](https://camo.githubusercontent.com/dcfa291a6b23d62be00ea780852e331ca67fc66083cfe4b9e1846433f716a2fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f626974666163746f72792d6e6c2f777071622f74657374732e796d6c)](https://camo.githubusercontent.com/dcfa291a6b23d62be00ea780852e331ca67fc66083cfe4b9e1846433f716a2fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f626974666163746f72792d6e6c2f777071622f74657374732e796d6c)

Description
-----------

[](#description)

WP Query Builder is a modern and extensible PHP library that offers a fluent, chainable interface to build and execute WordPress database queries. Instead of writing raw SQL or wrestling with WP's default methods, use this query builder to easily compose advanced queries.

If you like WPQB, please consider starring it.

### Features

[](#features)

- Fluent, chainable API for easy query composition.
- Support for various query types: SELECT, UPDATE, INSERT, and more. (under development)
- Built-in safeguards and helpers to avoid SQL injection.
- Supports advanced query features like joins, ordering, and limits.
- Integrated with the global $wpdb WordPress database object for query preparation and execution.
- 80%+ code coverage, so you can be sure the plugin works reliably.
- Perfect static analysis results.

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

[](#installation)

Simply download the latest release and put it in your plugins folder, or use the plugin installer in WordPress. You're ready to start writing kick-ass queries!

Basic usage
-----------

[](#basic-usage)

```
use Expedition\Wpqb\Query;

// Select query
$results = Query::select('name')
    ->distinct()
    ->from('wp_posts')
    ->where('post_status', '=', 'publish')
    ->where('post_type', '=', 'post')
    ->limit(10)
    ->orderBy('post_date', 'DESC')
    ->get();
```

Why WPQB instead of other plugins?
----------------------------------

[](#why-wpqb-instead-of-other-plugins)

There are other PHP packages out there that help you with query building such as `doctrine/dbal`. It's a brilliant package, it truly is. For WordPress, there are a few cons however:

- Because they don't deeply integrate with WordPress, they won't trigger all hooks, filters and caching mechanisms.
- You miss out on optimisations that have been done for `$wpdb`.
- A lot of extra overhead has to be imported, especially if it's an entire ORM.

These drawbacks are tackled by using this plugin.

Contribution
------------

[](#contribution)

Help is greatly appreciated here! There's a lot that still needs to be done, as it is currently just a weekend project. You can contribute in a lot of different ways:

- Writing tests
- Writing documentation (or examples for users of the plugin)
- Writing code
- Opening issues
- Tell others!

Tools
-----

[](#tools)

- PHPStan: Run PHPStan with `composer run-script phpstan`
- PHP RC Fixer: Run the PHP RC Fixer with `composer run-script phprcfix`
- PEST: Run PEST with `composer run-script test`

License
-------

[](#license)

This plugin is licensed under the MIT-license. Do whatever you like with it. Go conquer the world. Or don't.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 88.9% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a02fc2a61347d6950f96f92a05a453b6d67c6d7b2210fda4afeb90e3d55e4cd?d=identicon)[expedition-robin-martijn](/maintainers/expedition-robin-martijn)

---

Top Contributors

[![expedition-jeffrey-tempelman](https://avatars.githubusercontent.com/u/85357926?v=4)](https://github.com/expedition-jeffrey-tempelman "expedition-jeffrey-tempelman (24 commits)")[![expedition-thomas-bulten](https://avatars.githubusercontent.com/u/124870621?v=4)](https://github.com/expedition-thomas-bulten "expedition-thomas-bulten (3 commits)")

### Embed Badge

![Health badge](/badges/expedition-wpqb/health.svg)

```
[![Health](https://phpackages.com/badges/expedition-wpqb/health.svg)](https://phpackages.com/packages/expedition-wpqb)
```

PHPackages © 2026

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