webdevstudios / cmb2-post-search-field
为CMB2添加自定义字段,用于搜索/附加其他帖子ID的帖子搜索对话框。
v0.2.5
2016-05-30 06:58 UTC
Requires
- php: >5.2.4
Suggests
- composer/installers: ~1.0
This package is not auto-updated.
Last update: 2024-09-14 18:26:09 UTC
README
为CMB2添加自定义字段,用于搜索/附加其他帖子ID的帖子搜索对话框。
添加一个新的文本字段类型(带按钮)post_search_text
,用于快速搜索帖子对话框,并将帖子ID保存到文本输入框中。
示例
// Classic CMB2 declaration $cmb = new_cmb2_box( array( 'id' => 'prefix-metabox-id', 'title' => __( 'Post Info' ), 'object_types' => array( 'post', ), // Post type ) ); // Add new field $cmb->add_field( array( 'name' => __( 'Related post' ), 'id' => 'prefix_related_post', 'type' => 'post_search_text', // This field type // post type also as array 'post_type' => 'post', // Default is 'checkbox', used in the modal view to select the post type 'select_type' => 'radio', // Will replace any selection with selection from modal. Default is 'add' 'select_behavior' => 'replace', ) );
屏幕截图
如果您正在寻找一种更通用的方式来通过拖放界面附加帖子(或其他自定义帖子类型),您可能需要考虑使用 CMB2 Attached Posts Field。