Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. <?php /* Template Name: Question Form */
  2.  
  3. if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") {
  4.  
  5. // Do some minor form validation to make sure there is content
  6. if (isset ($_POST['title'])) {
  7. $title = $_POST['title'];
  8. } else {
  9. echo 'Please enter a title';
  10. }
  11. if (isset ($_POST['description'])) {
  12. $description = $_POST['description'];
  13. } else {
  14. echo 'Please enter the content';
  15. }
  16. $tags = $_POST['post_tags'];
  17. $industry = $_POST['trademan-industry'];
  18. $tcategory = $_POST['trademan-category'];
  19. $logo = $_POST['logo'];
  20.  
  21. // Add the content of the form to $post as an array
  22. $new_post = array(
  23. 'post_title' => $title,
  24. 'post_content' => $description,
  25. 'tags_input' => array($tags),
  26. 'post_address' => array($address),// not sure about this. actual ACF theme code is the_field('address');
  27. 'post_website' => array($website),// not sure about this. actual ACF theme code is the_field('website');
  28. 'post_logo' => array($logo),// here not sure code would be added to capture the logo as featured profile
  29.  
  30.  
  31. 'post_status' => 'draft', // Choose: publish, preview, future, draft, etc.
  32. 'post_type' => 'trademen' //'post',page' or use a custom post type if you want to
  33. );
  34. //save the new post
  35. $pid = wp_insert_post($new_post);
  36. wp_set_object_terms( $pid, $industry, 'trademan-industry');
  37. wp_redirect(get_permalink($pid)); exit;
  38. //insert taxonomies
  39. }
  40.  
  41. ?>
  42. <?php get_header(); ?>
  43.  
  44. <div id="wrap">
  45. <div id="header">
  46. <?php get_template_part('logo');
  47. get_template_part('nav'); ?>
  48. </div>
  49. <div id="content">
  50. <div id="main">
  51. <?php get_template_part('searches'); ?>
  52. <div class="single-post-item">
  53. <h1>Ask a Question</h1>
  54. <div class="post-meta">Fill out the fields below, all of them are required!</div>
  55. <div class="inner-content">
  56. <!-- New Post Form -->
  57. <div id="postbox">
  58. <form id="new_post" name="new_post" method="post" action="">
  59. <!-- post name -->
  60. <p><label for="title">Title</label><br />
  61. <input type="text" id="title" value="" tabindex="1" size="20" name="title" />
  62. </p>
  63.  
  64. <!-- post name -->
  65. <p><label for="title">Industry Sector</label><br />
  66. <input type="text" id="trademan-industry" value="" tabindex="2" size="20" name="trademan-industry" />
  67. </p>
  68.  
  69. <!-- post name -->
  70. <p><label for="title">Industry category</label><br />
  71. <input type="text" id="trademan-category" value="" tabindex="3" size="20" name="trademan-category" />
  72. </p>
  73.  
  74. <!-- post Content -->
  75. <p><label for="description">Content</label><br />
  76. <textarea id="description" tabindex="4" name="description" cols="50" rows="6"></textarea>
  77. </p>
  78.  
  79. <!-- logo -->
  80. <p><label for="logo">Logo</label><br />
  81. <input type="file" value="" tabindex="5" size="16" name="logo" id="logo" />
  82. </p>
  83.  
  84. <!-- ACF address -->
  85. <p><label for="address">Address:</label>
  86. <input type="text" value="" tabindex="6" size="16" name="address" id="address" /></p>
  87.  
  88. <!-- ACF website field -->
  89. <p><label for="website">website:</label>
  90. <input type="text" value="" tabindex="7" size="16" name="website" id="website" /></p>
  91.  
  92.  
  93. <p align="right"><input type="submit" value="Publish" tabindex="6" id="submit" name="submit" /></p>
  94.  
  95. <input type="hidden" name="action" value="new_post" />
  96. <?php wp_nonce_field( 'new-post' ); ?>
  97. </form>
  98.  
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <?php get_sidebar(); ?>
  104. </div>
  105. </div>
  106. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement