PHP code example of webdevstudios / cmb2-post-search-field
1. Go to this page and download the library: Download webdevstudios/cmb2-post-search-field library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webdevstudios / cmb2-post-search-field example snippets
// 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',
) );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.