webdevstudios/cmb2-post-search-field

Custom field for CMB2 which adds a post-search dialog for searching/attaching other post IDs.
48,838 66
Install
composer require webdevstudios/cmb2-post-search-field
Latest Version:v0.2.5
PHP:>5.2.4
License:GPL-2.0+
Last Updated:May 6, 2019
Links: GitHub  ·  Packagist
Maintainer: jtsternberg

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

// 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',
) );

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.

Related Packages

webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

65,991 134
justdev/inertia-wordpress

The WordPress adapter for Inertia.js

51 2
lara-press/framework

The LaraPress framework.

3,900 3
pressor/mu-plugin

Wordpress as a composer dependency in the context of a Laravel appliction. This...

9 0