More Related Content
Similar to Front End Publishing for WordPress
Similar to Front End Publishing for WordPress (20)
Front End Publishing for WordPress
- 1. Front End Publishing for A practical guide to enabling Front End Publishing on WordPress websites
- 30. Front End Form Example (1/2) <form id="new_post" name="new_post" method="post" action=""> <label for="title">Title</label><input type="text" id="title" value="" tabindex="1" size="20" name="title" /> <label for="description">Description</label><textarea id="description" tabindex="3" name="description" cols="50" rows="6"></textarea> <?php wp_dropdown_categories( 'show_option_none= Category&tab_index=4&taxonomy=category' ); ?>
- 31. Front End Form Example (2/2) <label for="post_tags">Tags</label><input type="text" value="" tabindex="5" size="16" name="post_tags" id="post_tags" /> <input type="submit" value="Publish" tabindex="6" id="submit" name="submit" /> <input type="hidden" name="post_type" id="post_type" value="post" /> <input type="hidden" name="action" value="post" /> <?php wp_nonce_field( 'new-post' ); ?></form>
- 32. Processing $_POST (1/2) <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) { if (isset ($_POST['title'])) {$title = $_POST['title'];} if (isset ($_POST['description'])) {$description = $_POST['description'];} $tags = $_POST['post_tags'];
- 33. Processing $_POST (2/2) $post = array('post_title' => $title,'post_content' => $description,'post_category' => $_POST['cat'], 'tags_input' => $tags,'post_status' => 'publish','post_type' => $_POST['post_type'] ); wp_insert_post($post); wp_redirect( home_url() );} do_action('wp_insert_post', 'wp_insert_post'); ?>