Shortcodes

(Created page with "Shortcodes are used in WordPress to execute pre-defined code and functions. == Shortcodes == === Form Shortcode ===")
(17 intermediate revisions not shown)
Line 1: Line 1:
-
Shortcodes are used in WordPress to execute pre-defined code and functions.
+
__TOC__
 +
Gravity Forms makes use of WordPress shortcodes to allow users to perform certain actions as well as display forms in WordPress pages and posts.  
-
== Shortcodes ==
+
== Form Shortcode ==
-
=== Form Shortcode ===
+
The form shortcode is used to display a Gravity Form.  It is the primary method used to display forms within your WordPress site. 
 +
 
 +
The form shortcode can be used anywhere within WordPress where shortcodes are supported.  For most users, this will primarily be within the content of a WordPress post or page.
 +
 
 +
Example:
 +
 
 +
<pre class="brush:php">[gravityform id=1 title=false description=false ajax=true]</pre>
 +
 
 +
*  '''id'''
 +
*: The id of the form to be embedded. ''(required)''
 +
*  '''title'''
 +
*: Whether or not do display the form title. Defaults to 'false'. ''(optional)''
 +
*  '''description'''
 +
*: Whether or not do display the form description. Defaults to 'false'. ''(optional)''
 +
*  '''ajax'''
 +
*: Specify whether or not to use AJAX to submit the form.
 +
*  '''tabindex'''
 +
*: Specify the starting tab index for the fields of this form.
 +
 
 +
A shortcode is just one method used to display a Gravity Form in WordPress.  Forms can also be displayed via function call or widget.  See [[Embedding A Form]] to read more detailed information on these various methods.
 +
 
 +
== Conditional Shortcode ==
 +
 
 +
The conditional shortcode allows you to perform conditional logic in the message content of your Admin and User Notification emails as well as the Confirmation Message that is displayed when a form is submitted.
 +
 
 +
The conditional shortcode consists of an opening and closing shortcode.  Any text or content contained within the opening and closing conditional shortcode will be the content that is conditionally displayed.
 +
 
 +
'''Example:'''
 +
 
 +
<pre class="brush:php">
 +
[gravityforms action="conditional" merge_tag="{Number:1}" condition="greater_than" value="3"]
 +
Content you would like to conditionally display.
 +
[/gravityforms]
 +
</pre>
 +
 
 +
*  '''action'''
 +
*: The action you would like to perform.  This must be set to conditional as in the example above. ''(required)''
 +
*  '''merge_tag'''
 +
*: The form merge tag who's value you are executing the conditional logic for. You can get the correct merge tag for the form data you would like to use using the insert merge tag drop down. ''(required)''
 +
*  '''condition'''
 +
*: The type of condition used to determine success.  Available conditions are: is, isnot, greater_than, less_than, contains, starts_with, ends_with. ''(required)''
 +
*  '''value'''
 +
*: The value that the condition must equal in order for the condition to be met and the content displayed. "(required)"
 +
 
 +
'''Additional Example 1:'''
 +
 
 +
<pre class="brush:php">
 +
[gravityforms action="conditional" merge_tag="{Number:1}" condition="greater_than" value="10"]
 +
This content would be displayed if the value of field id 1 is greater than 10.
 +
[/gravityforms]
 +
</pre>
 +
 
 +
'''Additional Example 2:'''
 +
 
 +
<pre class="brush:php">
 +
[gravityforms action="conditional" merge_tag="{Country:5}" condition="is" value="United States"]
 +
This content would be displayed if the value of field id 5 is United States.
 +
[/gravityforms]
 +
</pre>

Revision as of 20:24, 11 April 2012

Contents

Gravity Forms makes use of WordPress shortcodes to allow users to perform certain actions as well as display forms in WordPress pages and posts.

Form Shortcode

The form shortcode is used to display a Gravity Form. It is the primary method used to display forms within your WordPress site.

The form shortcode can be used anywhere within WordPress where shortcodes are supported. For most users, this will primarily be within the content of a WordPress post or page.

Example:

[gravityform id=1 title=false description=false ajax=true]
  • id
    The id of the form to be embedded. (required)
  • title
    Whether or not do display the form title. Defaults to 'false'. (optional)
  • description
    Whether or not do display the form description. Defaults to 'false'. (optional)
  • ajax
    Specify whether or not to use AJAX to submit the form.
  • tabindex
    Specify the starting tab index for the fields of this form.

A shortcode is just one method used to display a Gravity Form in WordPress. Forms can also be displayed via function call or widget. See Embedding A Form to read more detailed information on these various methods.

Conditional Shortcode

The conditional shortcode allows you to perform conditional logic in the message content of your Admin and User Notification emails as well as the Confirmation Message that is displayed when a form is submitted.

The conditional shortcode consists of an opening and closing shortcode. Any text or content contained within the opening and closing conditional shortcode will be the content that is conditionally displayed.

Example:

[gravityforms action="conditional" merge_tag="{Number:1}" condition="greater_than" value="3"]
Content you would like to conditionally display.
[/gravityforms]
  • action
    The action you would like to perform. This must be set to conditional as in the example above. (required)
  • merge_tag
    The form merge tag who's value you are executing the conditional logic for. You can get the correct merge tag for the form data you would like to use using the insert merge tag drop down. (required)
  • condition
    The type of condition used to determine success. Available conditions are: is, isnot, greater_than, less_than, contains, starts_with, ends_with. (required)
  • value
    The value that the condition must equal in order for the condition to be met and the content displayed. "(required)"

Additional Example 1:

[gravityforms action="conditional" merge_tag="{Number:1}" condition="greater_than" value="10"]
This content would be displayed if the value of field id 1 is greater than 10.
[/gravityforms]

Additional Example 2:

[gravityforms action="conditional" merge_tag="{Country:5}" condition="is" value="United States"]
This content would be displayed if the value of field id 5 is United States.
[/gravityforms]

Search the Documentation