Post from front end to custom metabox

I have a custom metabox in a custom post type. I’m using a front end posting page.
The information added by users in the form should be displayed in the post and appear in the back-end meta box in the custom meta boxe.

if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['submitted'] ) &&  $_POST['submitted'] == "new_post") {

    // Do some minor form validation to make sure there is content
    if (isset ($_POST['postTitle'])) {
        $title =  $_POST['postTitle'];
    } else {
        echo 'Please enter the wine name';
    }
    if (isset ($_POST['postContent'])) {
        $description = $_POST['postContent'];
    } else {
        echo 'Please enter some notes';
    }



    // ADD THE FORM INPUT TO $new_post ARRAY
    $new_post = array(
    'post_title'    =>  $title,
    'post_content'  =>  $description,
    'post_status'   =>  'pending',           // Choose: publish, preview, future, draft, etc.
    'post_type' =>  'portfolio'  //'post',page' or use a custom post type if you want to
    );

    //SAVE THE POST
    $pid = wp_insert_post($new_post);


    wp_redirect( home_url() );

} // END THE IF STATEMENT THAT STARTED THE WHOLE FORM

//POST THE POST YO
do_action('wp_insert_post', 'wp_insert_post');

get_header(); 

here is the form

<input type="text" id="short_description" name="short_description" style="padding: 7px; width: 100%;" value="<?php echo $short_description_no_html; ?>" />

Related posts

Leave a Reply