First off let me just say, I’m new to theme development, I hope there isn’t something obvious I’m missing.
I’m trying to get this form
contactform.php
<form method="POST" action="">
<input type="text" name="contact_name" placeholder="Name" class="form-control" required>
<input type="email" name="contact_email" placeholder="E-Mail" class="form-control" required>
<textarea name="contact_message" placeholder="Message" rows="4" class= "form-control" required></textarea>
<button type="submit" class="btn btn-secondary">Send</button>
</form>
<?php
//process request...
//redirect to previous page
global $wp;
wp_redirect(home_url($wp->request));
exit;
?>
Into the footer like so:
footer.php
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-sm">
Stuff
</div>
<div class="col-sm">
Stuff
</div>
<div class="col-sm">
<!-- form goes here -->
<?php get_template_part( 'contactform'); ?>
</div>
</div>
<div class="row">
<div class="col-sm">More stuff</div>
<div class="col-sm">More stuff</div>
<div class="col-sm">More stuff</div>
</div>
</div>
<?php wp_footer(); ?>
</footer>
The problem is, the second row is missing. It’s not in the DOM. But when I hardcode the form into the footer it works fine. So I figured there’s a problem with the get_template_part function.