Highlight Search Terms in Post Titles When Using Relevanssi

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', 'pure_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();