How to add new post or product with custom field in frontend?
-
-
Create page template for html form (not contact form) based on your requirements. Then you can I insert post by wp_insert_post method.
After that, you can update custom post by update_field() method.
Demo Code:-
|
if($_POST['title']){ $arr = $_POST['title']; $post_id = wp_insert_post($arr); update_field('extra_data', $_POST['extra_data'], $post_id ) } |
Custom field is based on acf plugin. You can retrieve custom field data by get_field method or get_post_meta method.
- You must be logged in to reply to this topic.