Support » Theme: Busiprof » Search Highlight

  • Resolved alexjackmann

    (@alexjackmann)



    I use the Relevanssi Plug-In for better Search in WordPress. But highlight the search result does not work.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Imran Ali

    (@imranaliweb)

    Hi @alexjackmann,

    Thanks for contacting us,

    Please share your website URL, we will check then assist you better.

    Thanks

    alexjackmann

    (@alexjackmann)

    hi @imranaliweb
    thanks for very fast feedback. http://alexander-jachmann.de
    Thanks a lot

    Imran Ali

    (@imranaliweb)

    Hi @alexjackmann

    It’s going to be perfect on our end like I have put it keine keyword in the search box and checked that it’s going to be okay, you can see the screenshot below.

    http://prntscr.com/icp2iz

    Thanks

    alexjackmann

    (@alexjackmann)

    hi @imranaliweb
    for example i use search box in the footer with the folloing result.

    if i us a other Theme like “Twenty Twelve”, the search Result looks like this.

    For better search i use the Wordpres Plug-In “Relevanssi”, in the settings you can configure how to highlight result.

    Thanks a lot

    Imran Ali

    (@imranaliweb)

    Hi @alexjackmann

    For this first of all install the Code Snippets plugin, you can install Code Snippets plugin while using this link.

    https://wordpress.org/plugins/code-snippets/

    Then paste the code given below into the snippets editor and activate snippets.

    function busiprof_highlight_results($text){
        if(is_search()){
    		$keys = implode('|', explode(' ', get_search_query()));
    		$text = preg_replace('/(' . $keys .')/iu', '<span class="search-highlight">\0</span>', $text);
        }
        return $text;
    }
    add_filter('the_content', 'busiprof_highlight_results');
    add_filter('the_excerpt', 'busiprof_highlight_results');
    add_filter('the_title', 'busiprof_highlight_results');
     
    function busiprof_highlight_results_css() {
    	?>
    	<style>
    	.search-highlight { background-color:#FF0; font-weight:bold; }
    	</style>
    	<?php
    }
    add_action('wp_head','busiprof_highlight_results_css');

    You can also follow this screenshot

    http://prntscr.com/icpmo0

    Any confusion lets me know.

    Thanks

    alexjackmann

    (@alexjackmann)

    Hi @imranaliweb
    thanks a lot. Very great Job!

    Imran Ali

    (@imranaliweb)

    Hi @alexjackmann,

    Glad to know it worked for you.

    If you get any issue later, feel free to ask again!

    We would really appreciate if you could provide us a review here:

    https://wordpress.org/support/theme/busiprof/reviews/#new-post

    Close this ticket !!!

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search Highlight’ is closed to new replies.