PHPackages                             dutchigor/cmb2-rest-query - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. dutchigor/cmb2-rest-query

ActiveWordpress-plugin[HTTP &amp; Networking](/categories/http)

dutchigor/cmb2-rest-query
=========================

Adds a query parameter to the REST API for any CMB2 field that has the property rest\_query set on it.

v1.0.1(6y ago)15GPL-3.0-or-laterPHPPHP &gt;7.0.0

Since Mar 30Pushed 6y ago3 watchersCompare

[ Source](https://github.com/dutchigor/CMB2-rest-query)[ Packagist](https://packagist.org/packages/dutchigor/cmb2-rest-query)[ Docs](https://github.com/dutchigor/CMB2-rest-query)[ RSS](/packages/dutchigor-cmb2-rest-query/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (3)Used By (0)

CMB2-rest-query
===============

[](#cmb2-rest-query)

Adds a query parameter to the REST API for any CMB2 field that has the property rest\_query set on it.

How to install
--------------

[](#how-to-install)

Option one

- Clone or download and unzip this plugin in to your WordPress plugin directory and active.

Option two

- Add dutchigor/cmb2-rest-query to required packages in composer and require CMB2-rest-query.php in your code

How to use
----------

[](#how-to-use)

### Setting up the metabox in CMB2

[](#setting-up-the-metabox-in-cmb2)

Add the query\_rest property to the field that you wish to query by in your CMB2 field configuration.

- If set to true, the field ID will used to query the REST API.
- If set to a value, the value will be used to query REST API.

#### Example

[](#example)

```
$cmb = new_cmb2_box( [
    'id'            => 'my_metabox',
    'title'         => __( 'My Metabox', 'cmb2' ),
    'object_types'  => [ 'post' ],
    'show_in_rest'  => WP_REST_Server::ALLMETHODS
] );

$cmb->add_field( [
    'id'            => 'my_text_field',
    'name'          => 'My text field',
    'type'          => 'text',
    'rest_query'    => true
] );

$cmb->add_field( [
    'id'            => 'custom_query_name',
    'name'          => 'My text field',
    'type'          => 'text',
    'rest_query'    => 'my_query'
] );
```

### Querying the REST API

[](#querying-the-rest-api)

For each field that has rest\_query set, 3 parameters will be available in the REST request on each post type that this field's metabox is registered on:

- the field's rest\_query value or id (as defined above)
- the above parameter appended with \_compare
- the above parameter appended with \_type

Adding the field's query parameter to the request will add that field to the request's meta query. By default compare will be '=' but using the {rest\_query}\_compare parameter, this can be changed to any option allowed by [WP\_Meta\_Query](https://developer.wordpress.org/reference/classes/wp_meta_query/). The type of the query parameter will be set to 'CHAR' by default but this can be overwritten using {rest\_query}\_type, again with the values allowd in WP\_Meta\_Query.

Following the above example a query could look like:

```
const request = new Request('https://wordpress.org/wp-json/wp/v2/posts?my_text_field=hello&my_query=world&my_query_compare=LIKE');
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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 ~0 days

Total

2

Last Release

2239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5fff5875562d3020e371c914420d0f293a4f2e53e2c6d328ce0b7c712902c259?d=identicon)[dutchigor](/maintainers/dutchigor)

---

Top Contributors

[![dutchigor](https://avatars.githubusercontent.com/u/38113768?v=4)](https://github.com/dutchigor "dutchigor (5 commits)")

---

Tags

searchwordpressrestmetaboxCMB2

### Embed Badge

![Health badge](/badges/dutchigor-cmb2-rest-query/health.svg)

```
[![Health](https://phpackages.com/badges/dutchigor-cmb2-rest-query/health.svg)](https://phpackages.com/packages/dutchigor-cmb2-rest-query)
```

###  Alternatives

[pixelpeter/laravel5-woocommerce-api-client

Laravel 5 wrapper for the Woocommerce REST API

125103.4k](/packages/pixelpeter-laravel5-woocommerce-api-client)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69114.3k](/packages/serpapi-google-search-results-php)[sdv/laravel-endpoint

Laravel Endpoint is a CRUD REST API package for Laravel.

1118.8k](/packages/sdv-laravel-endpoint)[threesquared/laravel-wp-api

Laravel package for the Wordpress JSON REST API

1310.3k](/packages/threesquared-laravel-wp-api)

PHPackages © 2026

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