PHPackages                             lordealeister/cmb2-field-post-search-ajax - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lordealeister/cmb2-field-post-search-ajax

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

lordealeister/cmb2-field-post-search-ajax
=========================================

CMB2 field type to attach posts to each others. Search with Ajax.

1.1.3(9y ago)0766GPL-3.0PHPPHP &gt;5.2.4

Since Mar 24Pushed 5y agoCompare

[ Source](https://github.com/lordealeister/cmb2-field-post-search-ajax)[ Packagist](https://packagist.org/packages/lordealeister/cmb2-field-post-search-ajax)[ Docs](https://github.com/alexis-magina/cmb2-field-post-search-ajax)[ RSS](/packages/lordealeister-cmb2-field-post-search-ajax/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (4)Used By (0)

CMB2 custom field "post\_search\_ajax"
======================================

[](#cmb2-custom-field-post_search_ajax)

Custom field for [CMB2](https://github.com/WebDevStudios/CMB2) to attach posts to each others.

Same approach than [CMB2 Attached Posts Field](https://github.com/WebDevStudios/cmb2-attached-posts/) with Ajax request, multiple/single option, and different UI.

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

[](#installation)

You can install this field type as you would a WordPress plugin:

- Download the plugin
- Place the plugin folder in your /wp-content/plugins/ directory
- Activate the plugin in the Plugin dashboard

Composer Intallation:

```
composer require alexis-magina/cmb2-field-post-search-ajax:dev-master

```

Usage - Admin
-------------

[](#usage---admin)

Follow the example in [`example-field-setup.php`](https://github.com/alexis-magina/cmb2-field-post-search-ajax/blob/master/example-field-setup.php) for a demonstration.

Options :

- limit (int, default = 1 : single selection) : limit the number of posts that can be selected
- sortable (bool, default = false) : Allow selected posts to be sort
- query\_args (array) : setup the ajax search query : pass a wp\_query args array.

Filter : (since 1.1.2) Ajax results can be filtered to customize returned text and posts values. Use filter "mag\_cmb\_post\_search\_ajax\_result", for example :

```
function example_callback( $arr ) {
	// $arr['data'] : contains post_id
	// $arr['guid'] : contains admin edit post url
	// $arr['value'] : contains post title
	$arr['value'] = 'Custom string '.$arr['value'];
    return $arr;
}
add_filter( 'mag_cmb_post_search_ajax_result', 'example_callback' );

```

Usage - FrontEnd
----------------

[](#usage---frontend)

You can retrieve the meta data using get\_post\_meta( get\_the\_ID(), 'your\_field\_id', true );

If field limit &gt; 1, this will return an array of attached post IDs. If field limit == 1, this will return only the single attached post ID.

Screenshot
----------

[](#screenshot)

[![example](https://github.com/alexis-magina/cmb2-field-post-search-ajax/raw/master/example.gif)](https://github.com/alexis-magina/cmb2-field-post-search-ajax/blob/master/example.gif)

Changelog
---------

[](#changelog)

### 1.0.0

[](#100)

- Initial commit

### 1.1.0-sebask

[](#110-sebask)

- Added a function which enables usage of CMB2 Field Post Search Ajax from a location other then the Wordpress Plugins folder.

### 1.1.1-sebask

[](#111-sebask)

- Fixed a minor bug which caused the use of an undefined constant.

### 1.1.2

[](#112)

- Fixed issue #2 : no way to delete value for fields with limit = 1
- Added a class exists check (issue #3)
- Added a filter "mag\_cmb\_post\_search\_ajax\_result" to allow customize ajax results
- Fixed a minor bug of encoding chars in autocomplete results

### 1.1.3

[](#113)

- Add Support for user queries
- Fixed issue #11 : sorting problem
- Fixed conflict with ui-autocomplete

### 1.1.4-sebask

[](#114-sebask)

- Fixed issue #14: safe mode for jquery-ui-autocomplete and devbridge/jQuery-Autocomplete compatibility.

### 1.1.5

[](#115)

- Fixed issue #17 : Undefined index if the field is empty

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

3

Last Release

3333d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/33c9e4981f59485bd5d0c11fb04855c69a68e00703433f26719613d63d5964c6?d=identicon)[lordealeister](/maintainers/lordealeister)

---

Top Contributors

[![alexis-magina](https://avatars.githubusercontent.com/u/5713738?v=4)](https://github.com/alexis-magina "alexis-magina (25 commits)")[![sebask](https://avatars.githubusercontent.com/u/2178774?v=4)](https://github.com/sebask "sebask (9 commits)")[![lordealeister](https://avatars.githubusercontent.com/u/3637910?v=4)](https://github.com/lordealeister "lordealeister (2 commits)")

---

Tags

pluginwordpresspostrelationshipmetaboxrelatedattached

### Embed Badge

![Health badge](/badges/lordealeister-cmb2-field-post-search-ajax/health.svg)

```
[![Health](https://phpackages.com/badges/lordealeister-cmb2-field-post-search-ajax/health.svg)](https://phpackages.com/packages/lordealeister-cmb2-field-post-search-ajax)
```

###  Alternatives

[webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

13565.5k](/packages/webdevstudios-cmb2-attached-posts)[alexis-magina/cmb2-field-post-search-ajax

CMB2 field type to attach posts to each others. Search with Ajax.

3913.4k1](/packages/alexis-magina-cmb2-field-post-search-ajax)[cmb2/cmb2

CMB2 is a metabox, custom fields, and forms library for WordPress that will blow your mind.

3.0k640.4k23](/packages/cmb2-cmb2)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[webdevstudios/cpt-core

WordPress Custom Post Type OO wrapper

807.7k1](/packages/webdevstudios-cpt-core)[iceicetimmy/acf-post-type-selector

Post type selector for Advanced Custom Fields.

559.0k](/packages/iceicetimmy-acf-post-type-selector)

PHPackages © 2026

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