Introduction
WordPress is a content management system (CMS) that is commonly used for blogging and building websites. Since you can publish webpages with WordPress, these pages can also support eTrigue forms like any other standard webpage.
However, WordPress has been known to alter code that is directly inserted onto a WordPress webpage. Unfortunately, this behavior doesn't play nicely when users have to insert scripts (e.g. Google Analytics, eTrigue Tracking Code) and other HTML elements (e.g. non-WordPress forms).
Here are examples of how WordPress may alter code.
Extra </p> tags are inserted which causes HTML to break.
Normal eTrigue code:
<input name="espFormID" type="hidden" value="100" />
How it looks after WordPress manages the code:
<input name="espFormID" type="hidden" value="100" /> </p>
The "onclick()" attribute is removed from the "submit" button causing the button to malfunction.
Normal eTrigue code:
<input class="button" id="etrSubmit" onclick="etr_submit();" type="button" value="submit" />
How it looks after WordPress manages the code:
<input id="etrSubmit" class="button" type="button" value="submit" />
WordPress deletes code
In some cases, WordPress will arbitrarily delete JavaScript on its own. This would affect eTrigue forms because the standard eTrigue form code includes JavaScript to handle field validation.
What should I do?
There are a number of options that allow you to insert the code. The most common methods are:
- Place the form code inside a theme or template file.
- Place your form code inside an external file and then have the web page reference that file.
- Implement a widget.
- Install a plugin to insert the code. An example is shown below.
Insert eTrigue Form Code With a Plugin
Within WordPress, many plugins exist today that facilitate the ability to insert custom code onto WordPress pages. In this support resource, we will use Insert HTML Snippet.
- Log into your WordPress site and navigate to Plugins > Add New.
- Install and activate the Insert HTML Snippet plugin. The plugin should install a new (side) navigation menu item called XYZ Html.
- Under XYZ Html > HTML Snippets, click Add New HTML Snippet.
- Provide a Tracking Name and paste your eTrigue's form code directly into HTML code.
- Click Create. Your snippet short code will be created.
- On your WordPress page, use the XYZ Html tool to insert your short code.
- Save and publish your page. Your form should be ready to go!