What it changes
This filter changes the HTML title attribute of each Better Search heatmap link. It does not change the heading above the heatmap or the visible search term.
What to change
Replace Search for %1$s with your preferred wording. Keep %1$s where the search term should appear. Register the function before the heatmap renders, using a custom functionality plugin or your child theme’s functions.php.
Requirements
- Better Search
- Better Search must be active and displaying a heatmap.
Source
better-search/bsearch-heatmap-title.php<?php
/**
* This is an example to replace the Better Search Heatmap title tag.
*
* @package Better_Search
*/
/**
* Filter the value of the title tag of heatmap links.
*
* @param string $title Value of the title tag of the link.
* @param string $searchvar Search term.
*/
function override_bsearch_heatmap_title( $title, $searchvar ) {
$title = sprintf(
/* translators: 1: Search term */
__( 'Search for %1$s', 'better-search' ),
$searchvar,
);
return $title;
}
add_filter( 'bsearch_heatmap_title', 'override_bsearch_heatmap_title', 10, 4 );Details
- Type
- Function snippet
- Last updated
- GitHub
- Source · Edit companion · History