Highlight Search Terms in Post Titles
You can configure Relevanssi to highlight search terms in result excerpts and result titles.
If you use the Genesis framework, the title highlighting won’t work. You can fix that by adding the following sippet to your search.php:
<?php
add_filter('genesis_post_title_output', 'wpkb_highlight_terms_in_search_result_title', 15);
function wpkb_highlight_terms_in_search_result_title($title)
{
$title = sprintf('<h2 class="entry-title" itemprop="headline"><a href="%s" rel="bookmark">%s</a></h2>', esc_url(relevanssi_get_permalink()), relevanssi_get_the_title(get_the_ID()));
return $title;
}
genesis();
Related Posts
- Highlight Search Terms in Post Titles When Using Relevanssi
- Configure WordPress Backend Search to Search Titles Only
- Shortcode to List (Custom) Taxonomy Terms
- Increase Upload Size when Using VestaCP
- Force Search Results to Show Excerpt When Using Genesis Framework
- Force Search Results to Show Excerpt