Closed mrfsrf closed 5 months ago
Can you verify whether or not you have this small style block being output in the <head>
of your search results page?
<style>
.algolia-search-highlight {
background-color: #fffbcc;
border-radius: 2px;
font-style: normal;
}
</style>
Also worth checking/confirming the Highlighting section of your index's configuration. If you've set anything specific for highlighting, you'd want to add in post_title
, and post_excerpt
. If you haven't customized that spot, then it should be applying to all searchable attributes of which, both of these are out of box with the plugin.
yup. the algolia-search-highlight css class is in the head. Second part i dont fully understand. Do you mean this?
Specifically the "UI Demos" around the top middle space in the image. If you're not using that "UI Demos" part, then I'm not quite sure which Display Preferences you're referring to.
Also make sure you're working with the wp_searchable_posts
index, with whatever prefix you chose, as that's going to be the index used for with Native Search template.
I created the UI demo and those are the results.
What im baffled about is that method highlight_the_title
(inside Algolia_Search
class) for example is not logging out
public function highlight_the_title( $title, $post_id ) {
error_log("Highlighting title for post ID: $post_id");
$highlighted_title = $this->current_page_hits[ $post_id ]['_highlightResult']['post_title']['value'] ?? null;
if ( ! empty( $highlighted_title ) ) {
$title = $highlighted_title;
}
return $title;
}
I'd be able to troubleshoot a lot better with a link to the live page where the issue is happening, as opposed to their UI Demos area. The demo area is not where the issue is.
The highlight_the_title()
method should be getting called on the the_title
filter, so if you're not using that in your theme, that may be why that one is failing.
Just to be certain, this spot on the right of the screenshot, for your index, is empty, correct?
If empty, then as the text says, all searchable attributes should be getting the highlight treatment.
Thanks! Manged to solved it. Had to call correct filters on title and excerpt
Glad to hear you got things figured out :)
Describe the bug For some reason i dont have search highlight on results. Tried to error log inside
class-algolia-search.php
inside methodpre_get_posts
inside the debug.log there is:
[_highlightResult] => Array
. Also made sure that highlightning is enabledwhich is true. Do i miss something?
Im using Use Algolia with the native WordPress search template as an option