search

This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6292
    onir
    onir
    Participant

    Hi
    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

    #6293
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #6332
    onir
    onir
    Participant

    Hi Ernest

    I’ve found this plugin https://wordpress.org/plugins/highlight-search-terms/
    Is it possible to integrate it with Ajax Search Pro?

    thanks
    Ed

    #6334
    onir
    onir
    Participant

    Also, 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/

    #6335
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    The 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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.