Creating the form
We’ll begin by creating a new form and at the very top of the form, we’re going to add an HTML form field. This will have a mixture of text and HTML so we can dynamically display the title which will include the current school year.
Once you’ve added your HTML field, you’ll need to add inside your Code section.
You can select this text and copy it to add it to your form.
<h1>School Registration</h1> <h2>For the school year <span id="last-year"></span> to <span id="next-year"></span></h2>
Inside each of the span IDs, a year will dynamically be added. For example, inside the last-year will contain the beginning school year and inside the next-year will contain the ending school year.
If you need any help in creating your form, please review this documentation.
Adding the snippet
Now it’s time to add the snippet that will populate these years for us.
If you’re not sure how or where to add snippets, please check out this tutorial.
With this snippet we’re pulling the current year to display for the next-year and for the last-year we’re taking the current year and using math subtracting one year.
And that’s it! Would you like to also provide a live word count under your text field? Take a look at our tutorial on How to Display a Total Word Count Under Your Form Field.
Action Reference: wpforms_wp_footer_end