Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Before I post this question, I've seen many questions in here but I guess, it still makes me confused and have no idea to implemented it.

Case: I've just made Testimonial Custom Post Type by WPtuts Tutorial.

I have made and set it up well on my template. But Now I need a Front-end Form for that. But I don't know to make and from where to start it.

In case, In testimonials custom post type, I have 3 custom meta boxes that needed to show and can be submitted well.

Please kindly your help for this, I'm sorry for my bad English.

This is the code what i've made, but didn't work

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

if (isset($_POST['submit'])) {
    $error = "";

    if ($_POST['location'] != null) {
    $location = trim(strip_tags($_POST['location']));
    } else {
    $error .= 'Put location.</br>';
    }           
} 

        $testimonial_data= $_POST['_testimonial'];
        $client_name= $_POST['client_name'];
        $source= $_POST['source'];
        $link= $_POST['link'];

    if (empty($error)) {   
    $new_post = array(   //insert form inputs, set var and define array
    'post_content'  =>  $description,
    'post_status'   =>  'draft',
    'post_author'   =>  '2',
    '_testimonial'        => $testimonial_data,
    'client_name'        => $client_name,
    'source'        => $source,
    'link'     => $link,
    'post_type' => 'post'
    'post_category' => array($_POST['testimonials']),  // Usable for custom taxonomies too

    // assigning tags and categories are no issue
    );

    $pid = wp_insert_post($new_post);

//ADD OUR CUSTOM FIELDS 
add_post_meta($pid, '_testimonial', $testimonial_data, false);                          
add_post_meta($pid, 'client_name', $client_name, false);        
add_post_meta($pid, 'source', $source, false);        
add_post_meta($pid, 'link', $link, false);        
} 
}

and this is the code for the form

                <p><label for="title">Nama Anda</label><br />
                <input type="text" id="client_name[]" value="" tabindex="1" size="20" name="client_name" />
                </p>

                <p><label for="title">Title Website Anda</label><br />
                <input type="text" id="source[]" value="" tabindex="1" size="20" name="source" />
                </p>

                <p><label for="title">Link Website Anda</label><br />
                <input type="text" id="link[]" value="" tabindex="1" size="20" name="link" />
                </p>

                <p><label for="description">Testimonial</label><br />
                <textarea id="description" tabindex="3" name="description" cols="50" rows="6"></textarea>
                </p>

                 <input type="hidden" name="action" value="post_action" />
                 <input type="submit" name="submit" id="submit" value="PROCEED"/>
                 <?php wp_nonce_field( 'new-post' ); ?>
share|improve this question
    
please help me! –  user46044 Feb 3 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.