I have created an sign up form and placed it in my header:
<div>
<h5 class="myapp-sign-up-text">Sign up for updates</h5>
<form class="myapp-email-form">
<input type="text" name="email" placeholder="Your email address" class="myapp-subscription-input" />
<input type="submit" value="Subscribe" class="myapp-subscription-submit" />
</form>
</div>
I would like to use the same code for my footer. Is there a DRY way of putting this into a partial and loading it using a PHP function?
I have created an sign up form and placed it in my header:
<div>
<h5 class="myapp-sign-up-text">Sign up for updates</h5>
<form class="myapp-email-form">
<input type="text" name="email" placeholder="Your email address" class="myapp-subscription-input" />
<input type="submit" value="Subscribe" class="myapp-subscription-submit" />
</form>
</div>
I would like to use the same code for my footer. Is there a DRY way of putting this into a partial and loading it using a PHP function?
The thing you're searching for is get_template_part
function.
So let's say you put your form in file called part-form-signup.php
. Then you can easily include that partial template anywhere using:
get_template_part( 'part-form-signup' );