How To Create Fancy Highlight search-result


Sponsored Links




Use this tiny hack to Highlight search-result on WordPress. Open search.php and Replace the_exerpt() with:

echo $excerpt;

And then add the following just before the edited line:

$excerpt = get_the_excerpt();
$keys = explode(" ",$s);
$excerpt = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $excerpt);

Now the last step is add .search-excerpt class your style.css and do whatever style you really like it. That’s it.

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net

WordPress Tricks / WordPress Tricks & Tips

How To Create Fancy Highlight search-result. Use this tiny hack to Highlight search-result on WordPress. Open search.php Read More

Highlighting Search Keywords in a DataGrid Web Control

You can "fancy it up" as you see fit. To learn more (Note for this to work you will need to create a page InputTxt - The text from the search result "hit". StartTag - The Read More

PHP Example AJAX Live Search

AJAX can be used to create more user-friendly and interactive searches. Read More

PHP highlight search keywords - PHP.help! : resources for web

performing a search, it’s ofter very useful to highlight you’re highlighting has HTML markup, it will create a MooToolTips – fancy tooltips; MyTube – YouTube player Read More

DLS Tutorial: using jQuery selectors in gleeBox to make cool "ESP

Google search result page, it somehow knows to automatically highlight the It's a fancy name you want to highlight. In this tutorial I will show you how to create Read More


One Response to How To Create Fancy Highlight search-result

  1. Menchie says:

    Thanks for the details. Let me try it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>