Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /* Template Name: Question Form */
- if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") {
- // Do some minor form validation to make sure there is content
- 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';
- }
- $tags = $_POST['post_tags'];
- $industry = $_POST['trademan-industry'];
- $tcategory = $_POST['trademan-category'];
- $logo = $_POST['logo'];
- // Add the content of the form to $post as an array
- $new_post = array(
- 'post_title' => $title,
- 'post_content' => $description,
- 'tags_input' => array($tags),
- 'post_address' => array($address),// not sure about this. actual ACF theme code is the_field('address');
- 'post_website' => array($website),// not sure about this. actual ACF theme code is the_field('website');
- 'post_logo' => array($logo),// here not sure code would be added to capture the logo as featured profile
- 'post_status' => 'draft', // Choose: publish, preview, future, draft, etc.
- 'post_type' => 'trademen' //'post',page' or use a custom post type if you want to
- );
- //save the new post
- $pid = wp_insert_post($new_post);
- wp_set_object_terms( $pid, $industry, 'trademan-industry');
- wp_redirect(get_permalink($pid)); exit;
- //insert taxonomies
- }
- ?>
- <?php get_header(); ?>
- <div id="wrap">
- <div id="header">
- <?php get_template_part('logo');
- get_template_part('nav'); ?>
- </div>
- <div id="content">
- <div id="main">
- <?php get_template_part('searches'); ?>
- <div class="single-post-item">
- <h1>Ask a Question</h1>
- <div class="post-meta">Fill out the fields below, all of them are required!</div>
- <div class="inner-content">
- <!-- New Post Form -->
- <div id="postbox">
- <form id="new_post" name="new_post" method="post" action="">
- <!-- post name -->
- <p><label for="title">Title</label><br />
- <input type="text" id="title" value="" tabindex="1" size="20" name="title" />
- </p>
- <!-- post name -->
- <p><label for="title">Industry Sector</label><br />
- <input type="text" id="trademan-industry" value="" tabindex="2" size="20" name="trademan-industry" />
- </p>
- <!-- post name -->
- <p><label for="title">Industry category</label><br />
- <input type="text" id="trademan-category" value="" tabindex="3" size="20" name="trademan-category" />
- </p>
- <!-- post Content -->
- <p><label for="description">Content</label><br />
- <textarea id="description" tabindex="4" name="description" cols="50" rows="6"></textarea>
- </p>
- <!-- logo -->
- <p><label for="logo">Logo</label><br />
- <input type="file" value="" tabindex="5" size="16" name="logo" id="logo" />
- </p>
- <!-- ACF address -->
- <p><label for="address">Address:</label>
- <input type="text" value="" tabindex="6" size="16" name="address" id="address" /></p>
- <!-- ACF website field -->
- <p><label for="website">website:</label>
- <input type="text" value="" tabindex="7" size="16" name="website" id="website" /></p>
- <p align="right"><input type="submit" value="Publish" tabindex="6" id="submit" name="submit" /></p>
- <input type="hidden" name="action" value="new_post" />
- <?php wp_nonce_field( 'new-post' ); ?>
- </form>
- </div>
- </div>
- </div>
- </div>
- <?php get_sidebar(); ?>
- </div>
- </div>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement