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.
pickup.php
<!-- 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>
<p><label for="address">Address</label><br />
<input type="text" id="address" value="" tabindex="1" size="20" name="address" />
</p>
<p><label for="Phone">Phone</label><br />
<input type="text" id="Phone" value="" tabindex="1" size="20" name="Phone" />
</p>
<?php wp_nonce_field( 'new-post' ); //Apparently needed for security ?>
</form>
</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 -->
