I planning now simple plugin, i search for idea to adding subposts (child) for post in wordpress on post creation page.
I want to add form with two fields, title and content, and save it with parent ID of current parent post.
Simple mockup:
For create subpost i can use this:
$post = array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_parent' => id of post
);
wp_insert_post($post);
But i want do this dynamic with ajax, but on create page i dont have parent post ID. Someone have ideas for this?