admin管理员组

文章数量:1332361

I am trying to learn how to build contact form from scratch without plugin. I came across this tutorial

I am not understanding why we need to put contact form code inside the loop as shown in the tutorial. Out of curiousity I tried putting my code within page-contact.php without using the loop and it was rendered out correctly. I didn't start implementing php code yet. I checked Codex about the_post and the_content tags and what they do within the loop. Say the_content pulls in from database the content of the page or post. So why my markup works without the loop and those tags?

my current page-contact.php

<?php get_header();?>

<main>
     
    <form  method="GET" action="form.html" class="contact">
     
     <div class="field-wrap">
      <div>
        <input type="text" name="name" id="name" required/>
        <label for="name">Name</label>
      </div>

      <div>
        <input type="text" name="email" id="email" required/>
        <label for="email">Email</label>
      </div>
    </div>
    
    
      <div class="message">
        <textarea name="message" id="message" cols="30" rows="25" required></textarea>
        <label for="message">Message</label>
      </div>  

      <button>Submit</button>
    
    </form>

   
</main>    


<?php get_footer();?>

本文标签: contact form and WP loop