项目作者: CMB2

项目描述 :
Custom field for CMB2 which adds a post-search dialog for searching/attaching other post IDs
高级语言: PHP
项目地址: git://github.com/CMB2/CMB2-Post-Search-field.git
创建时间: 2014-09-22T20:50:11Z
项目社区:https://github.com/CMB2/CMB2-Post-Search-field

开源协议:

下载


CMB2 Post Search field

Custom field for CMB2 which adds a post-search dialog for searching/attaching other post IDs.

Adds a new text field type (with a button), post_search_text that adds a quick post search dialog for saving post IDs to a text input.

Example

  1. // Classic CMB2 declaration
  2. $cmb = new_cmb2_box( array(
  3. 'id' => 'prefix-metabox-id',
  4. 'title' => __( 'Post Info' ),
  5. 'object_types' => array( 'post', ), // Post type
  6. ) );
  7. // Add new field
  8. $cmb->add_field( array(
  9. 'name' => __( 'Related post' ),
  10. 'id' => 'prefix_related_post',
  11. 'type' => 'post_search_text', // This field type
  12. // post type also as array
  13. 'post_type' => 'post',
  14. // Default is 'checkbox', used in the modal view to select the post type
  15. 'select_type' => 'radio',
  16. // Will replace any selection with selection from modal. Default is 'add'
  17. 'select_behavior' => 'replace',
  18. ) );

Screenshots

  1. Field display
    Field display

  2. Search Modal
    Search Modal


If you’re looking for a more general way to attach posts (or other custom post types) with a drag and drop interface, you might consider CMB2 Attached Posts Field instead.