It was meant just to show the result and the lack of broken markup.
I’ve tried with TwentyTwentyTwo as well.
Here’s the title markup that came of it:
<a target="_self"><em class="algolia-search-highlight">DDP</em> Yoga</a>
and for a visual, I have also provided a screenshot.
So at least at this point, it’s still a matter of the attribute being rendered as part of the results template.
I’m presently curious if the template is applying the the_title
filter to this spot, as here’s the code we have for highlight with native search template plus title results. Or perhaps title="<?php the_title(); ?>"
public function highlight_the_title( $title, $post_id ) {
$highlighted_title = $this->current_page_hits[ $post_id ]['_highlightResult']['post_title']['value'] ?? null;
if ( ! empty( $highlighted_title ) ) {
$title = $highlighted_title;
}
return $title;
}
add_filter( 'the_title', [ $this, 'highlight_the_title' ], 10, 2 );
Essentially replacing the title value with the returned highlighted result from Algolia. In your example case, it’s being output as part of an attribute instead of say inside some <h2></h2>
tags or similar.