PHP code example of dutchigor / cmb2-rest-query

1. Go to this page and download the library: Download dutchigor/cmb2-rest-query 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/ */

    

dutchigor / cmb2-rest-query example snippets


$cmb = new_cmb2_box( [
    'id'            => 'my_metabox',
    'title'         => __( 'My Metabox', 'cmb2' ),
    'object_types'  => [ 'post' ],
    'show_in_rest'  => WP_REST_Server::ALLMETHODS
] );

$cmb->add_field( [
    'id'            => 'my_text_field',
    'name'          => 'My text field',
    'type'          => 'text',
    'rest_query'    => true
] );

$cmb->add_field( [
    'id'            => 'custom_query_name',
    'name'          => 'My text field',
    'type'          => 'text',
    'rest_query'    => 'my_query'
] );