CMB2 Field Type: Post Search Ajax
CMB2 field type to attach posts to each others.
by Magina · github.com/alexis-magina/cmb2-field-post-search-ajax · website
★ 39stars
14kcomposer installs
17forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/alexis-magina/cmb2-field-post-search-ajax/archive/refs/heads/master.zipAlso on Packagist as alexis-magina/cmb2-field-post-search-ajax:
composer require alexis-magina/cmb2-field-post-search-ajaxDeclares an update source (https://github.com/alexis-magina/cmb2-field-post-search-ajax), so updates arrive through the plugin's own updater.
From the readme
CMB2 custom field "postsearchajax"
Custom field for CMB2 to attach posts to each others.
Same approach than CMB2 Attached Posts Field with Ajax request, multiple/single option, and different UI.
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:
Usage - Admin
Follow the example in 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
- queryargs (array) : setup the ajax search query : pass a wpquery args array.
Filter : (since 1.1.2)
Ajax results can be filtered to customize returned text and posts values.
Use filter "magcmbpostsearchajaxresult", for example :
Usage - FrontEnd
You can retrieve the meta data using getpostmeta( gettheID(), 'yourfieldid', true );
If field limit 1, this will return an array of attached post IDs.
If field limit == 1, this will return only the single attached post ID.
Screenshot
Changelog
1.0.0
Read the full README on GitHub →
Releases
These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.