从前端发布到自定义元变量

时间:2012-12-18 00:29:28

标签: wordpress

我在自定义帖子类型中有自定义元数据箱。我正在使用前端发布页面。 用户在表单中添加的信息应显示在帖子中,并显示在自定义元框的后端元​​框中。

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(); 

这是表格

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

0 个答案:

没有答案