- October 25, 2016 at 5:57 am #10588
How to highlight a search key word at any place of the post?
I have a post which has around 45,000 characters (or 7500 words). When I run a search, it highlights keywords up to 1500 characters (or 270 words). If the keyword is after that many words, I get just search results, but the keyword with a highlight is not visible. Please check the attachment.
How to fix this issue?
Attachments:You must be logged in to view attached files.October 25, 2016 at 6:32 am #10592
The contextual algorithm is limited on purpose to the first 1800 characters (roughly 300 words) programatically. While it’s highly optimized from various sources, I still implemented this limit for safety – as in some cases it might require much more memory as usual. Not a critical value, but I had to consider it.
You can lift this limit by editing one of the plugin files. Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-search-cpt.php file on your server and scroll to line 1710, which should be this one:
$haystack = wd_substr_at_word(ASP_mb::strtolower($haystack), 1800);
and change that line to:
$haystack = wd_substr_at_word(ASP_mb::strtolower($haystack), 300000);
This will allow strings up to 300 thousands of characters instead of the initial 1800. However in case you experience any kind of performance problems, then please try reducing it to a lower number.Best,
If you like my products, don't forget to rate them on codecanyon :)
You must be logged in to reply to this topic.