i using following function register new custom post type on wp site.
function new_projects() { $args = array( 'label' => 'our projects', 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => 'our-projects'), 'query_var' => true, 'show_in_menu' => 'themes.php', 'menu_icon' => 'dashicons-awards', 'can_export'=> false, 'menu_position' => 100, 'supports' => array( 'title', 'editor', ) ); register_post_type( 'our-projects', $args ); } add_action( 'init', 'new_projects' ); and it's registering new custom post type named our projects.
now, want auto create post under custom post type namely 'our projects' or so.
how can execute this?
thanks
use wp_insert_post function insert posts in database. add code.
// create post object $my_post = array( 'post_title' => 'our projects', 'post_content' => 'this auto created post under projects.', 'post_status' => 'publish', 'post_type' => 'our-projects', ); // insert post database wp_insert_post( $my_post );
Comments
Post a Comment