GFSearch Shortcode
GFSearch
A powerful and flexible Gravity Forms search and display shortcode for WordPress.
š Description
TheĀ GFSearchĀ shortcode enables advanced searching and displaying of Gravity Forms entries on your posts, pages,
Gravity Views, or custom templates. It functions similarly to an ExcelĀ VLOOKUP, allows filtering results, sorting entries, custom formatting, and much moreāall
tailored to your exact needs.
⨠Key Features
- Form Targeting:Ā Search entries across all forms, specific forms, or selected forms via IDs.
- Field Filtering:Ā Search or display multiple fields simultaneously using field IDs and corresponding values.
- Custom Formatting:Ā Customize output using placeholders and HTML formatting, supporting field data and meta-properties.
- Sorting Options:Ā Primary and secondary sorting by ascending, descending, or random order.
- Comparison Filters:Ā Filter numeric fields by values (greater than or less than).
- Global Search:Ā Search all form fields for specific values easily.
- Unique Results:Ā Eliminate duplicate entries by enabling theĀ
unique
Ā option. - Advanced Search Modes:Ā Match any condition (
search_mode="any"
) or all conditions (default). - HTML Supported in Display:Ā Fully supports HTML inĀ
display
Ā andĀseparator
Ā attributes, e.g.,Ā<li>
Ā for lists. - Search for Empty Fields:Ā Identify and display entries with missing field data.
- Entry Linking:Ā Convert results into links to entry admin panel views.
š Usage
To use the shortcode, embed in your content areas with relevant attributes, e.g.:Ā
Example 2: Search and Display Multiple Fields
Example 3: Display Unique Results with Links
This will return a list of unique created_by values from form 3. Each will link to its corresponding admin entry view.
Unique Entry: 1
</tbody>
</table>
You can create links to anywhere you want, including other views or parts of this view!
Example 6: Secondary Sort
š¼ļø Display Attribute
TheĀ display
attribute controls what is shown for each matching entry. You can use it in two different formats, comma-separated field list and a custom display string. Read more about the GFSearch display attribute.
𧬠Nested Shortcodes
You can include shortcodes inside theĀ display
Ā attribute usingĀ double curly bracesĀ ({{ ... }}
Ā syntax). This allows you to embed other shortcodesālikeĀ gravitymath
,Ā gfsearch
or any other shortcodeāwithin the output for each entry. Read more about nesting shortcodes in GFSearch.
āļø Operators Attribute
TheĀ operators
Ā attribute allows you to defineĀ how each search value is comparedĀ to its corresponding field in theĀ search
Ā attribute. It should be aĀ comma-separated list, with each operator matching its position to the same-positioned field ID in theĀ search
attribute. Read more about using operators with GFSearch.
ā Notes and Best Practices
- To search multiple fields pass comma separated IDs to the search attribute and separate the corresponding values in
the shortcode content with theĀ|
Ā symbol. Use theĀsearch_mode
Ā attribute to configure if any or all conditions must
match. To search for multiple values for the same field, repeat the field ID in the search attribute with the corresponding values in the shortcode content. - Custom Formatting: Use the display attribute with placeholders, enabling displays in a complex format.
You can create lists or tables, link to entries in a Gravity View, createĀmailto
Ā links, the possibilities are almost
endless! You can define CSS classes allowing for even more customization! See above for details. - The search and display attributes both support entry properties and field IDs. SeeĀ Gravity Forms Entry Object.
- To perform a global search for any field with a specified value, leave the corresponding search ID blank.
- To display values from a field without searching, omit the search attribute and shortcode content.
- Sorting:
UseĀsort_key
Ā (field ID, entry property, or entry meta key),Āsort_direction
Ā (ASC
,ĀDESC
Ā (default),ĀRAND
),
andĀsort_is_num
Ā (true
/false
). For secondary sorting, useĀsecondary_sort_key
Ā andĀsecondary_sort_direction
.
Secondary sorting is ignored if primary sort direction isĀRAND
.
Please note that dates are numeric regarding theĀsort_is_num
Ā attribute. - Use theĀ
unique
Ā attribute with any non-empty value to return only unique results.Ā Please Note:Ā that if the results
are not exactly the same they will be treated as unique. So the results example.comĀ and example.conĀ as a typo
will be considered unique. - To search for empty values, leave the shortcode content blank and use theĀ
search_empty
Ā attribute with any non-empty value. - Use theĀ
default
Ā attribute to specify a value to display when no results are found or for blank values within entries. - Use theĀ
link
Ā attribute with any non-empty value to wrap each result in a link to the entry view page in the WordPress admin. - When using the shortcode content to pass in search values (separated by the | character), avoid using the pipe (|)
symbol inside the actual values themselves. Escaping is not currently supported, so including a pipe within a value may
result in incorrect or partial matches. - TheĀ
Ā shortcode does not restrict access by default. Anyone who can view the page can see the search results, including Gravity Forms entry data.
To protect sensitive information, place the shortcode inside pages with appropriate access controls (e.g., membership plugins, password protection, or role-based visibility). - EachĀ
Ā shortcode runs a live database query. Using many shortcodes, large forms, or limit="all" can slow down page loads.
To improve speed:- Use limit to cap results
- Minimize nested shortcodes
- Consider caching the page output
- If there are more search IDs than values, extra fields will search for blank entries. Extra values beyond the number of IDs are ignored.
š§© Multi-Input Field Support
Multi-input fieldsāsuch asĀ Name,Ā Address, andĀ CheckboxĀ fieldsācontain multiple inputs within a single field.
This snippet supports both displaying and searching these fields, but the behavior differs slightly between display and search. Read more about multi-input field support with GFSearch.
Installation
This shortcode can be installed as a snippet or as a plugin.
As a Plugin
Download the zipĀ and install in the WP admin dashboard.
As a snippet
Copy the code fromĀ here
and install in your themes functions.php file or with your favorite code snippets plugin.
š License
This plugin is licensed underĀ GPLv2 or later.
š Links
This code is best installed directly on your site using the Code Snippets plugin.
Loading...