Wordpress前端发布用the_excerpt替换描述

时间:2013-08-12 00:27:19

标签: php wordpress forms frontend custom-fields

我已经创建了这个前端表单,我想用th_excerpt替换描述我该怎么办?提前致谢

<?php
/*
Template Name: add
*/
?>
<?php
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {
    // Do some minor form validation to make sure there is content
    if (isset ($_POST['title'])) {
        $title =  $_POST['title'];
    } else {
        echo 'Titolo film';
    }
    if (isset ($_POST['description'])) {
        $description = $_POST['description'];
    } else {
        echo 'Trama (max 100 caratteri)';
    }
    $tags = $_POST['post_tags'];
    $regista = $_POST['regista'];
    $yapim = $_POST['yapim'];
    $anno = $_POST['anno'];
    $durata = $_POST['durata'];
    $resim = $_POST['resim'];
    $trama = $_POST['trama'];
    $imdb = $_POST['imdb'];
    // ADD THE FORM INPUT TO $new_post ARRAY
    $new_post = array(
    'post_title'    =>  $title,
    'post_content'  =>  $description,
    'post_category' =>  array($_POST['cat']),  // Usable for custom taxonomies too
    'tags_input'    =>  array($tags),
    'post_status'   =>  'draft',           // Choose: publish, preview, future, draft, etc.
    'post_type' =>  'post',  //'post',page' or use a custom post type if you want to
    'regista'   =>  $regista,
    'yapim' =>  $yapim, 
    'durata'    =>  $durata,
    'imdb'  =>  $imdb,
    'resim' =>  $resim,
    'trama' =>  $trama,
    'anno'  =>  $anno,
    );
    //SAVE THE POST
    $pid = wp_insert_post($new_post);
    //KEEPS OUR COMMA SEPARATED TAGS AS INDIVIDUAL
    wp_set_post_tags($pid, $_POST['post_tags']);
    wp_set_post_terms($pid, array($_POST['regista']),'regista',true); 
    wp_set_post_terms($pid, array($_POST['anno']),'anno',true); 

    //REDIRECT TO THE NEW POST ON SAVE
    $link = 'http://99filmstreaming.com/grazie/'; 
    wp_redirect( $link );
    //ADD OUR CUSTOM FIELDS
    add_post_meta($pid, 'regista', $regista, true); 
    add_post_meta($pid, 'yapim', $yapim, true); 
    add_post_meta($pid, 'durata', $durata, true); 
    add_post_meta($pid, 'imdb', $imdb, true);
    add_post_meta($pid, 'trama', $trama, true); 
    add_post_meta($pid, 'resim', $resim, true); 
    add_post_meta($pid, 'anno', $anno, true);

    //INSERT OUR MEDIA ATTACHMENTS
    if ($_FILES) {
        foreach ($_FILES as $file => $array) {
        $newupload = insert_attachment($file,$pid);
        // $newupload returns the attachment id of the file that
        // was just uploaded. Do whatever you want with that now.
        }
    } // END THE IF STATEMENT FOR FILES
} // END THE IF STATEMENT THAT STARTED THE WHOLE FORM
//POST THE POST YO
do_action('wp_insert_post', 'wp_insert_post');
?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
    <div id="primary" class="hfeed">
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
            <div id="post-<?php the_ID(); ?>" class="post">
    <div class="single_head">
        <h2> <?php the_title(); ?> </h2>
    </div>
        <div id="iletisim_kapsul">
          <div class="aciklama">
                <form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
                <ul class="contactform">
                    <li><label for="title">Titolo</label>
                    <input type="text" id="title" value="" tabindex="5" name="title" /></li>
                    <li><label for="resim">Url Locandina</label>
                    <input type="text" value="" id="resim" tabindex="30" name="resim" /></li>
                    <li><label for="regista">Regia</label>
                    <input type="text" value="" id="regista" tabindex="20" name="regista" /></li>
                    <li><label for="anno">Anno</label>
                    <input type="text" value="" id="anno" tabindex="20" name="anno" /></li>
                    <li><label for="durata">Durata</label>
                    <input type="text" value="" id="durata" tabindex="20" name="durata" /></li>
                    <li><label for="yapim">Produzione</label>
                    <input type="text" value="" id="yapim" tabindex="20" name="yapim" /></li>
                    <li><label for="cat">Genere</label>
                    <?php wp_dropdown_categories( 'tab_index=20&taxonomy=category&hide_empty=0' ); ?></li>
                    <li><label for="imdb">IMDB</label>
                    <input type="text" value="" id="imdb" tabindex="20" name="imdb" /></li>
                    <li><label for="post_tags">Attori</label>
                    <input type="text" value="" tabindex="35" name="post_tags" id="post_tags" /></li>
                    <li><label for="trama">Trama</label>
                    <textarea id="trama" tabindex="20" name="trama" cols="60" rows="3" placeholder="Inserisci la trama del film, max 150 caratteri.."></textarea></li>
                    <li><label for="description">Video</label>
                    <textarea id="description" tabindex="20" name="description" cols="60" rows="10" placeholder="Inserisci il codice iframe del video.."></textarea></li>
                    <li class="buttons">
                    <button type="submit" value="Pubblica" name="submit" id="btn-send">Pubblica Film!</button>
                    <input type="hidden" name="action" value="new_post" />
                    <?php wp_nonce_field( 'new-post' ); ?>
                    </li>
              </ul>
            </form>
          </div>
        </div>
    <?php endwhile; // end of the loop. ?>
    </div>
</div>
<?php get_footer(); ?>

在此处查看来源film streaming

1 个答案:

答案 0 :(得分:0)

更改以下内容:

'post_content'  =>  $description,

要:

'post_excerpt'  =>  $description,