wordpress - wp_insert_post() returns null -
i creating page , childpages, using wp_insert_post(), whenever post made in custom post type. pages created fine wp_insert_post() not return id of childpages, instead returns null.
$mainparr = array( 'post_title' => $value, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => ' ', 'comment_status' => 'closed', 'post_name' => $course_slug, 'menu_order' => 0, ); $mainp_id=wp_insert_post( $mainparr, false); update_post_meta($post->id,'course_page_id',$mainp_id); $dokarr = array( 'post_title' => 'dokumenter', 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => ' ', 'comment_status' => 'closed', 'post_name' => 'dokumenter', 'post_parent' => $mainp_id, 'menu_order' => 0, ); $dokid = wp_insert_post( $dokarr, false );
the $mainp_id returned fine childpages $dokid return null, doing wrong?
nevermind found error. wp_insert_post_does return id, had different function overriding value of id before output, bad.
Comments
Post a Comment