Search Templates & Merge Tags
Introduction
Gravity Search provides flexible options for displaying Target Form entry data in search results, map info windows,
and individual entry displays.
You can build output using configurable Structured Fields or write your own Custom HTML with merge tags. Merge tags
dynamically insert field values, entry information, distance data, and Details Page links for the entry being
displayed.

Output Modes
Structured Fields
Structured Fields mode builds the output from settings such as:
- Title Field
- Main Image Field
- Show Distance
- Show Details Link
- Display Rows
The available settings vary slightly between Search Results, Map Info Windows, and Details Display, but the general
workflow is the same: select the fields you want to display and configure their labels and layout.
Use Structured Fields when you want consistent output without maintaining custom markup.

Custom HTML
Select Custom HTML as the Output Mode when you need to create your own markup.
Depending on the section you are configuring, the HTML editor is labeled:
- Result Item HTML under Results settings.
- Table Header HTML when using a table results template.
- Info Window HTML under Map settings.
- Details HTML under Details Display settings.
Use the merge-tag selector beside the editor when available to insert Target Form fields without entering field IDs
manually.

Supported Merge Tags
Merge tags are replaced with data from the current Target Form entry when the output is rendered.
Where Output Modes Are Used
- Results: Choose Structured Fields or Custom HTML for each result item.
- Map Info Windows: Choose Structured Fields or Custom HTML for marker info-window content.
- Details Display: Choose Structured Fields, Custom HTML, or Page Content for individual entries.
For Details Display, Structured Fields and Custom HTML appear where the [gfgeo_search_entry]
shortcode is placed on the selected Details Page.
Page Content works differently. It processes the selected WordPress page content and resolves
supported merge tags using values from the current entry. The shortcode is not required when using Page Content mode.
Custom HTML Examples
Basic Result Item
<div class="directory-item">
<h3>{field:1|details_link}</h3>
<p>{field:3}</p>
<p>{distance_with_units}</p>
</div>
Result Item With an Image
<div class="directory-card">
{field:5|image}
<h3>{field:1|details_link}</h3>
<p>{field:2}</p>
{details_link|View Full Details}
</div>
Table Result Row
<tr>
<td>{field:1|details_link}</td>
<td>{field:3}</td>
<td>{distance_with_units}</td>
<td>{date_created|format:Y-m-d}</td>
</tr>
When using a table results template, enter the column headings separately in the Table Header HTML
setting.
Best Practices
- Start with Structured Fields unless your layout requires custom markup.
- Use the merge-tag selector when available to avoid entering incorrect field IDs.
- Keep display markup in the output settings and configure search behavior elsewhere in Search Settings.
- Test Custom HTML with entries containing empty fields and missing images.
- Test distance tags both with and without an active proximity search.
- Configure and test the Details Page under Search Setup → Details Routing before adding details links to results or info windows.
- Use valid table markup when creating custom table headers and result rows.
