Better Search provides two shortcodes: [bsearch_heatmap] and [bsearch_form]. These are available in both the free and pro versions of the plugin and can display a heatmap of popular searches or embed a customizable search form. Better Search Pro adds [bsearch_ai] for AI answers.

1. [bsearch_form]

Better Search can work with any search form on your site. However, it also includes its own advanced search form that allows you to display and pass post types where you’d like to allow users to search only within one or more post types.

This shortcode embeds a customizable Better Search form anywhere on your site.

Attributes for bsearch_form

AttributeTypeDescription
beforeStringText or HTML to display before the search form.
afterStringText or HTML to display after the search form.
aria_labelStringARIA label for the search form (accessibility).
post_typesString (csv)Post types to search (comma-separated list).
selected_post_typesString (csv)Preselect post types in the dropdown (comma-separated list).
show_post_typesBooleanShow a dropdown to select post types (1 or 0).
ai_mode (pro only)StringAsk AI button for this form: default (use the global setting), alongside, replace or off.
ai_text (pro only)StringAsk AI button text for this form.

Example Usage

This example wraps the search form in a custom div and includes a dropdown for post-type selection.

[bsearch_form before="<div class='search-wrapper'>" after="</div>" show_post_types="true"]

2. [bsearch_heatmap]

This shortcode generates a heatmap of your site’s popular search terms. Various attributes allow you to customize its appearance and functionality.

Attributes for bsearch_heatmap

AttributeTypeDescription
dailyBooleanDisplay searches from the past X days (1 or 0).
daily_rangeIntegerNumber of days for the daily heatmap.
smallestIntegerSmallest font size for the heatmap.
largestIntegerLargest font size for the heatmap.
unitStringFont size unit (px, pt, etc.).
hotString (hex)Color for the most popular searches.
coldString (hex)Color for the least popular searches.
numberIntegerMaximum number of terms to display.
before_termStringText or HTML before each search term.
after_termStringText or HTML after each search term.
link_nofollowBooleanAdds rel="nofollow" to links (1 or 0).
link_new_windowBooleanOpens links in a new tab (1 or 0).
formatStringHeatmap format: flat (inline), array or list.
separatorStringSeparator for terms when format is flat.
orderbyStringHow to order terms: count or name.
orderStringOrder direction: ASC, DESC or RAND.
topic_count_textStringCustom text for displaying term counts.
show_countBooleanShow the count of searches for each term (1 or 0).
no_results_textStringThis text is displayed when there are no search terms available.

Example Usage

This example shows a heatmap of the top 10 daily searches with custom font sizes and colors.

[bsearch_heatmap daily="1" number="10" smallest="10" largest="20" hot="#ff0000" cold="#cccccc"]

3. [bsearch_ai] (Pro only)

This shortcode shows a standalone question box for AI answers. It has no attributes and uses the Search form buttons and Ask AI button text settings on the AI settings tab. Nothing is shown when AI answers are off or WordPress has no AI Client.

[bsearch_ai]

Was this article helpful?