Better Search provides two powerful shortcodes: [bsearch_heatmap] and [bsearch_form]. These are available in both the free and Pro versions of the plugin and can be used to display a heatmap of popular searches or embed a customisable search form.

1. [bsearch_heatmap]

This shortcode generates a heatmap of popular search terms on your site. You can customise its appearance and functionality using various attributes.

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)Colour for the most popular searches.
coldString (hex)Colour 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_textStringText to display 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 colours.

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

2. [bsearch_form]

This shortcode embeds a customisable 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).

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"]