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

How To Highlight Searched text in Search Results

For Some reason we need to Highlight searched text in our WordPress Search Results. I know there are many plugin able to handle it. But on today WordPress tutorial, we will do it using function. No Plugin needed. To create … Read More

How To Change WordPress Search Result URL

Did you know, we can change WordPress Search Result URL using htaccess? We are have know, WordPress search result URL is un-pretty. You browser result will be displayed such as http://wptricks.net/?s=WP+Tricks I thinks this URL didn't good

Tutorial To Display a Different Number of Post on Search Result

Did you know that, WordPress search result have the same number of post with original WordPress loop, you can check your setting on Settings » Reading » Blog pages show at most. But for some reason, we need to show … Read More

Create you own Excerpt in WordPress

Sometimes we need to limit how many words will be displayed in our excerpt, If you have use WordPress 2.9.x you can use Easy Excerpt method, but if you want something different, you can create own excerpt and replace your … Read More

How To Exclude Pages or Posts from Search Results Page

For some reason, sometimes we need to exclude some contents on our WordPress site from search results in our WordPress. Example we didn't need to display our about page to be indexed or searchable by WordPress search. To enable this … Read More

The Right Way Highlight Author Comments in WordPress

This Tricks original written by AEXT.net and we only share and to make it more clearly, especially for me. How To Highlight Author Comments in WordPress in the right way. This code is better for the future and better for … Read More

The Best Daily WordPress Tricks & Tips

Menchie on How To Create Fancy Highlight search-result; Very Useful 65 Wordpress Hacks | Stevelizardi.com on How to Fix readfile Problem on TimThumb read more

Source: http://wptricks.net/

WP Tricks Authors / WordPress Tricks & Tips

Menchie on How To Create Fancy Highlight search-result; Very Useful 65 Wordpress Hacks | Stevelizardi.com on How to Fix readfile Problem on TimThumb read more

Source: http://wptricks.net/author/admin/

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

Source: http://www.4guysfromrolla.com/articles/072402-1.aspx

HTML span tag - How to use HTML span styles

HTML span tutorials. XHTML elements including span tag. Learn how to create HTML hover text, to add a background image to text. As well as how to highlight text read more

Source: http://www.hypergurl.com/span.html

Advertising | Facebook

Ads Reach over 800 million people where they connect Create an Ad read more

Source: http://www.facebook.com/advertising/?pages


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>