I am attempting to create a form that submits data and creates a post with custom fields filled. What I would like to do in step form.

1) Create a custom posttype function called "pickups" (I do not know how to do this)

2) Inside Pickups I need a function to created 5 separate columns which will be populated from the post types custom field.

3) Build a Form that will populate those 5 columns as a new postype(not sure if that is the correct term)

4) Then I need to output this data I am assuming with short code to a page.

Here is some code I have found, however parts of it will need to be modified and the postype function will still need to be built.


<!-- New Post Form -->

<div id="postbox">
<form id="new_post" name="new_post" method="post" action="">
<p><label for="name">Name</label><br />
<input type="text" id="name" value="" tabindex="1" size="20" name="name" />
<p><label for="address">Address</label><br />
<input type="text" id="address" value="" tabindex="1" size="20" name="address" />
<p><label for="Phone">Phone</label><br />
<input type="text" id="Phone" value="" tabindex="1" size="20" name="Phone" />
<?php wp_nonce_field( 'new-post' ); //Apparently needed for security ?> 
</div><!--postbox ends-->

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

    // Do some minor form validation to make sure there is content
    if (isset ($_POST['name'])) {
        $name =  $_POST['name'];
    } else {
        echo 'Please enter a name';
    // Repeat this for each input field

    // Add the content of the form to $post as an array
    $post = array(
        'post_name' => $name,
        'post_address'  => $address,
        'post_phone'    => $phone,

    wp_insert_post($post);  // Pass  the value of $post to WordPress the insert function
                            // http://codex.wordpress.org/Function_Reference/wp_insert_post
    wp_redirect( home_url() );
} // end IF

// Do the wp_insert_post action to insert it
do_action('wp_insert_post', 'wp_insert_post'); 


<!--// New Post Form -->

1 Answer 1



Refer above link, we can check user logged in or not in fronted and pass custom post type too while saving post in database.

  • this doesn't have anything about making the custom-postype this just shows how to add to a regular post Commented Jan 25, 2012 at 6:09
  • @AndersKitson please read all tutorial , before calling wp_insert_post($post); in $post array you can pass 'post_type' whatever you want ie your custom post type. Its explained there well.
    – amolv
    Commented Jan 25, 2012 at 6:14
  • I have read the whole tutorial, I am still trying to figure out how to create columns in a custom post-type. Commented Jan 25, 2012 at 6:24
  • @AndersKitson what you mean 'create columns in a custom post-type.'?
    – amolv
    Commented Jan 25, 2012 at 6:48
  • something like this, wordpress.stackexchange.com/questions/28413/… Commented Jan 25, 2012 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.