Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /* Template Name: Test Form */ get_header();
- if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") {
- if (isset ($_POST['title'])) {
- $title = $_POST['title'];
- } else {
- echo 'Please enter a title';
- }
- if (isset ($_POST['description'])) {
- $description = $_POST['description'];
- } else {
- echo 'Please enter the content';
- }
- if (isset ($_POST['domain'])) {
- $domain = esc_attr($_POST['domain']);
- } else {
- echo 'Please enter the domain';
- }
- if (isset ($_POST['keywords'])) {
- $keywords = sanitize_text_field ($_POST['keywords']);
- } else {
- echo 'Please enter the keywords';
- }
- $tags = $_POST['post_tags'];
- $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' => 'publish', // Choose: publish, preview, future, draft, etc.
- 'post_type' => 'website' //'post',page' or use a custom post type if you want to
- );
- $pid = wp_insert_post($new_post);
- update_post_meta($pid,'domain',$domain);
- update_post_meta($pid,'keywords',$keywords);
- wp_redirect( get_permalink($pid) );
- exit();
- //insert taxonomies
- } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement