update readme
This commit is contained in:
parent
eafb9e174e
commit
78e17f02ab
30
readme.md
30
readme.md
|
@ -7,7 +7,7 @@ Custom fields for [CMB2](https://github.com/WebDevStudios/CMB2) to attach posts,
|
|||
|
||||
Once activated, this plugin adds three new field types `post_ajax_search`, `user_ajax_search` and `term_ajax_search`.
|
||||
|
||||
This plugin is an update of [CMB2 Field Type: Post Search Ajax](https://github.com/alexis-magina/cmb2-field-post-search-ajax) by [Magina](http://magina.fr/) with support to attach posts, users or terms.
|
||||
This plugin is a fork of [CMB2 Field Type: Ajax Search](https://github.com/rubengc/cmb2-field-ajax-search) which is an update of [CMB2 Field Type: Post Search Ajax](https://github.com/alexis-magina/cmb2-field-post-search-ajax) by [Magina](http://magina.fr/) with support to attach posts, users or terms.
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -19,6 +19,11 @@ You can install this field type as you would a WordPress plugin:
|
|||
|
||||
## Parameters
|
||||
|
||||
This fork adds the option of specifying a CSS selector as an attribute `data-id-element` on the ajax search field.
|
||||
The specified field will then be given the value of the ID of the selected post.
|
||||
The ajax search field will then show the actual value selected.
|
||||
See example for usage.
|
||||
|
||||
Options :
|
||||
- multiple (bool, default = false) : Turn field into a multiple attached objects
|
||||
- limit (int, default = -1 : single selection) : Limit the number of posts that can be selected (-1 for unlimited)
|
||||
|
@ -124,6 +129,29 @@ function cmb2_ajax_search_metabox() {
|
|||
}
|
||||
```
|
||||
|
||||
```php
|
||||
$cmb_demo->add_field( array(
|
||||
'name' => __( 'Data ID', 'cmb2' ),
|
||||
'desc' => __( 'Field description (optional), 'cmb2' ),
|
||||
'id' => 'mps_meta_poster_movie_ajax',
|
||||
'save_field' => false,
|
||||
'type' => '#post_ajax_search_hidden',
|
||||
'query_args' => array(
|
||||
'post_type' => array( 'post' ),
|
||||
'posts_per_page' => -1,
|
||||
),
|
||||
'attributes' => array(
|
||||
'data-id-element' => '#mps_meta_poster_movie_id',
|
||||
),
|
||||
) );
|
||||
|
||||
$cmb_demo->add_field( array(
|
||||
'name' => __( 'Data ID Hidden', 'cmb2' ),
|
||||
'id' => 'post_ajax_search_hidden',
|
||||
'type' => 'hidden',
|
||||
) );
|
||||
```
|
||||
|
||||
## Customize results output
|
||||
|
||||
You can use `cmb_{$field_id}_ajax_search_result_text` to customize the text returned from ajax searches and `cmb_{$field_id}_ajax_search_result_link` to customize the link, check next example:
|
||||
|
|
Loading…
Reference in New Issue