Need to insert custom post type objects from code. Haven’t been able to add using the default method
$id = wp_insert_post(array('post_title'=>'random', 'post_type'=>'custom_post'));
creates a regular post instead.
Need to insert custom post type objects from code. Haven’t been able to add using the default method
$id = wp_insert_post(array('post_title'=>'random', 'post_type'=>'custom_post'));
creates a regular post instead.
From the Codex:
wp_insert_post() will fill out a default list of these but the
user is required to provide the title and content otherwise the
database write will fail.
$id = wp_insert_post(array(
'post_title'=>'random',
'post_type'=>'custom_post',
'post_content'=>'demo text'
));