How to Create a Custom Form Template

Would you like to create your own custom form templates? Custom templates enable you to build and use your own unique “starter” forms. If you tend to use many of the same fields and settings in your forms, or if you want to use the same form across multiple sites running WPForms, this can be a huge time saver.

In this tutorial, we’ll show you how to create your own custom form templates from a new or existing form.

  1. Creating a Form to Use as a Template
  2. Exporting Form Code to Create a Template
  3. Adding Template Code to Your Site
  4. Using Your New Custom Template
  5. Deleting the Original Form Template (Optional)
  6. Frequently Asked Questions

First, make sure WPForms is installed and activated on your site. Then you can dive into the tutorial below.

1. Creating a Form to Use as a Template

To begin, you need a form that will later be copied to create your template. You can use an existing form or create a new one.

When creating a new form, you can choose to either start with a blank form or use one of our existing templates and customize it.

On the Setup page, enter the name of your template in the Name Your Form field.

Naming a new form to use as a template

This title will be visible in the template library once you add your custom template to it, so make sure it’s something descriptive but not too long.

Adding and Customizing Fields

You can add fields to your template form by clicking on them in the panel on the left of the form builder, or by dragging and dropping them into the preview area.

Adding a Checkboxes field to a form

You can click on any field in the preview panel to open and customize its field options.

Customizing field options to use in a form template

Note: Looking for more guidance on setting up your template’s fields? You can learn more about all the available options in our tutorials on choosing the right form fields and customizing field options.

You may also want to consider adding conditional logic to your template form or creating a multi-column layout. All of your changes and customizations will be carried over into your template.

Configuring Form Settings

You can also customize your template form’s settings to configure default settings for future forms that will use this template. All changes to your settings will carry over when you export this form to use it as a template.

General

In your form’s General settings, you can edit your template’s title and add a description.

Customizing the description for a custom template form

Both of these will later be visible in the template library, so it’s a good idea to customize them. Make sure your description includes any key details for people using your template, such as its intended purpose.

Here you can also edit the submit button text, toggle anti-spam protection on or off, and add custom CSS if you wish.

Notifications

In your template form’s notifications settings, you can create one or more default notifications for your template.

Customizing the default notification for a custom template

Note: Need help customizing your template’s notifications? Check out our tutorial on setting up notification emails for more details.

Confirmations

You can change your template’s default confirmation in your confirmations settings.

Customizing the default confirmation for a new custom template

Note: Want to learn more about creating form confirmations? See our guide to WPForms’ confirmations settings.

When you’re happy with your template, save your changes by clicking on the Save button in the top right corner of the form builder.

Then click on the X to exit the form builder.

2. Exporting Form Code to Create a Template

Now that you’ve set up your template form, you can export it to add it to the template library.

First, you’ll need to get your template’s code by going to WPForms » Tools and clicking on the Export tab.

Accessing the WPForms Export tools

On this page, scroll down to the Form Template Export section, which provides a dropdown list of all of your forms. Select the form you created to use as your template and click the Export Template button.

Exporting a custom form template

The template code will then be generated and displayed on your screen.

The export code for a custom template

Copying and pasting this code to your site files will display this template in the form template library on the Setup page of the form builder.

3. Adding Template Code to Your Site

We’ll discuss three methods for adding your exported template’s code to your site. For all of these options, you’ll first need to make sure you have access to your site files.

All of the following options will work for adding the template to the same site you build it on, or to another site.

Copying and Pasting Template Code to functions.php

If you would like the easiest and fastest solution for adding your custom template to your site, this is the way to go.

Open your site’s functions.php file by going to /wp-content/themes/YOUR-THEME/functions.php in your site’s files.

Then you can copy and paste the template code directly into functions.php. Save the file when you’re done.

Note: Keep in mind that any custom code in functions.php can potentially disappear if you run an update for your theme. You can avoid this by creating a child theme or using a custom plugin as described below.

Pasting Template Code into a New PHP File and Including It in functions.php

This method is very similar to the first one we covered, except that you will put the template code in its own file. This will help to protect it from accidental changes and keep your site’s code more organized.

If you choose this option, you will first need to open your site’s functions.php file in /wp-content/themes/YOUR-THEME/functions.php. Then paste in the following code:

// Add Custom Template File
include_once( get_stylesheet_directory() . '/wpforms-custom-templates.php' );

This tells your site to run the code in a file named wpforms-custom-templates.php. Next, you need to make that file. Be sure to create it in /wp-content/themes/YOUR-THEME/ (the same folder as functions.php).

Lastly, you’ll need to paste the template code into the wpforms-custom-templates.php file and save it.

Note: When creating your wpforms-custom-templates.php file, you must add <?php at the top of the file above the template code generated by the export tool. This is required for the file to be valid and for this method to work.

Creating a Custom Plugin

This is the best option if you expect to change your WordPress theme in the future or want to use the same template(s) on multiple sites.

Creating a plugin might sound complex, but in this case, it actually only requires a few steps.

First, create a new file in your text or code editor and paste in the following:

<?php
/**
 * Plugin Name: WPForms Custom Templates
 * Description: This plugin loads custom form templates.
 * Version:     1.0.0
 */

/**
 * Load the templates.
 */
function wpf_load_custom_templates() {

	// Template code here

}
add_action( 'wpforms_loaded', 'wpf_load_custom_templates' );

Replace // Template code here with the generated code from the export tool and save the file as wpforms-custom-templates.php.

Then open your site files and navigate to /wp-content/plugins/. Save wpforms-custom-templates.php to this folder to install your plugin on your site.

On your WordPress site, open the Plugins page. There should be a plugin named WPForms Custom Templates. Click on Activate to activate your plugin.

Activating a custom plugin to add your custom template code to your site

4. Using Your New Custom Template

Once you’ve completed one of the three methods described above, your template should be ready to go!

To check that everything is working, go to WPForms » Add New. In the menu on the left side of the template library, click on Custom Templates.

Accessing the Custom Templates category in the form template library

Here you should see your custom template, including the form title and description you added earlier.

Using your custom form template

You can use it as you would any other form template.

5. Deleting the Original Form Template (Optional)

Lastly, you can delete the form you created in the first step if you like. The template doesn’t rely on the original form in any way, so you only have to keep it if it has associated entries that you need.

To delete the form, go to WPForms » All Forms, hover over the form’s row, and click Delete.

Deleting the original template form

Frequently Asked Questions

These are some of the most common questions we receive related to custom form templates.

Can I create a custom template without using code?

If you don’t feel confident following this tutorial and adding code to your site’s files, you can use our plugin’s duplicate functionality instead.

This method will not add a new template to your plugin’s template library. However, it can still save you time when creating new forms that use repeating fields and/or settings.

First, create your template form as described in the first step of this tutorial. Then go to WPForms » All Forms, hover over your template form, and click Duplicate.

Duplicating a form to use it as a template

This will create a new form that is an exact copy of your template form, including its settings. You can create and customize as many duplicates of the original as you need.

If you would like to use this template on multiple sites, you can use our import and export tools to migrate it to another WordPress site that uses WPForms.

Note: Think your template should be included in our template library? Feel free to send us your suggestion. We’d love to hear it!

That’s it! You can now save time by making your own custom form templates in WPForms.

Want to personalize your forms even more? Check out our guide on how to customize your WPForms validation messages.