I have a custom post type which is used to add sections to a front page, for example ‘PHP section with brief description of PHP’.
In these sections will be a link to a page which expands on the brief description given in the post (not a link to the post).
I want to take away the responsibility of the user adding the corresponding page manually by inserting code which will check if a new post of ‘custom_post_type’ is being inserted and add a page of the same name, with default content ready for the user to edit.
I can’t find the function in the WP core which adds the post.
Can anyone offer any help? I assume it is the wp_write_post function in wp-admin/post.php called by write_post() in the same script, but I’ve tried a couple of things.
1. Inserting a wp_insert_post() to insert the corresponding page (didn’t work)
2. Commenting out wp_write_post() to break the application when a post is added, however the post was still added when this was the case which left me perplexed!
Any suggestions on where to insert the code or another way of doing it?