Skip to content
Advertisement

Custom Page Template Deleted after generating new custom post from Form

I have a custom post type and a custom page template with a form field. The user enters the data and custom metadata in the form field, submits it, a new custom post is generated with the values passed to it. It all works fine except for one thing. When you submit the data it deletes the custom page template. I’ve no idea why this is happening and would appreciate the help in finding where the problem is and how to fix it.

JavaScript

HTML

JavaScript

Advertisement

Answer

Got it working by…..

Changing – $post_id = wp_update_post( $business_listing );

To – $post_id = wp_insert_post( $business_listing );

And Added:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement