Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › search
- This topic has 4 replies, 2 voices, and was last updated 10 years, 7 months ago by
Ernest Marcinko.
-
AuthorPosts
-
October 16, 2015 at 3:03 pm #6292
onir
ParticipantHi
once a search is done how to highlight the word searched on the page.
example: search “car”. on the result page I want to highlight the word “car” everywhere its found.thanks
October 16, 2015 at 3:07 pm #6293Ernest Marcinko
KeymasterHi!
I’m afraid it’s not possible. If you want, I can add this as a feature request for a future version, but I cannot promise anything, as I’m not sure if it’s actually doable.
October 17, 2015 at 11:17 am #6332onir
ParticipantHi Ernest
I’ve found this plugin https://wordpress.org/plugins/highlight-search-terms/
Is it possible to integrate it with Ajax Search Pro?thanks
EdOctober 17, 2015 at 11:31 am #6334onir
ParticipantAlso, as this is a quite important feature to me, can I suggest a “click two times” method at least?
So a second (optional of course, set in the control panel) button that appears just after the document has been loaded to highlight the term searched in the page. In that way the code used will be independent from the actual search, you just need to pass to this button the word previously searched.
there are some solutions about this on the net, but of course not directly applicable here. anyway just to highlight (pun intended) that this is a quite common feature.
http://www.wpbeginner.com/wp-tutorials/how-to-highlight-the-search-terms-in-results-in-wordpress/October 17, 2015 at 11:44 am #6335Ernest Marcinko
KeymasterThe problem with your request is that you want to highlight the term on the actual single result page, not on the search results page, that’s a very big difference. I highly doubt any of these solutions will be helpful in this case.
There is a highlighter in the search included but it only works on the ajax results not on the actual results page.
One solution might be to pass an extra get parameter with the search results url. It is possible to change the result url wihtout changin the code using the proper filter, here is an example: https://wp-dreams.com/knowledge-base/how-to-change-the-results-url-to-something-else/
So like adding an extra parameter, something like:$results[$k]->link .= “?highlight=” . $search_phrase;
But then again the $search_phrase variable is not defined, so you will have to somehow get it there, I don’t know how.
Then with another filter you will have to change the content or connect with the highlighter plugin somehow, because now the
$_GET[‘highlight’]
variable contains the highlightable phrase.
But then again, that’s just a suggestion from the top of my head. This is way beyond the plugin capabilities. I can give you suggestions or help, but I’m afraid I can’t solve this for you right now.
-
AuthorPosts
- You must be logged in to reply to this topic.