Create POST and add Custom Post Meta
-
I can create a new post with the REST api. I POST to: https://site.dev/wp-json/wp/v2/posts with Basic Auth and include the following key/values in the Body using x-www-form-urlencoded
title, content, status, excerpt.
I have also created a custom field using CMB2:
` // create the metabox
$cmb = new_cmb2_box( array(
‘id’ => ‘site_meta’,
‘title’ => ‘Site Metabox’,
‘object_types’ => array( ‘sites’ ), // post type
‘context’ => ‘normal’, // ‘normal’, ‘advanced’ or ‘side’
‘priority’ => ‘high’, // ‘high’, ‘core’, ‘default’ or ‘low’
‘show_names’ => true, // show field names on the left
‘cmb_styles’ => true, // false to disable the CMB stylesheet
‘closed’ => true, // keep the metabox closed by default
) );$cmb->add_field( array(
‘name’ => ‘Site URL’,
‘id’ => ‘site_url’,
‘type’ => ‘text_url’,
) );`Any ideas how I can send site_url and add to this custom field along with the title, content etc..
Thanks
- The topic ‘Create POST and add Custom Post Meta’ is closed to new replies.