GFSearch Shortcode – Code Snippet Directory

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


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.

Install Using Code Snippets

This code is best installed directly on your site using the Code Snippets plugin.

Check Out the Code

Loading...

Code Copied!
Stay Updated On This Snippet

One review of this entry No Rating