Posted in Featured, Tutorials, Wordpress

Like this post? Share It :
  • Print
  • email
  • PDF
  • Google Bookmarks
  • Facebook
  • Twitter
  • MySpace
  • Yahoo! Buzz
  • del.icio.us
  • Digg
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Reddit
  • Technorati
  • Design Float
  • RSS

How To Highlight Search Results In WordPress

You can highlight the search result for your users/visitors, and help them find the related content more quickly and easily. This simple tutorial will help you along.

Procedure:

Note: Do take backup of the file you try this.

01. Replace the_exerpt() code in search.php file with:

class=”code”>echo $ excerpt;

 

02. Now just below the replaced code add these lines:

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

 

03. Edit the class .search-excerpt as you want your highlight to look.

This concludes this simple and useful tutorial. Hope you like it.


TutZone

Like this post? Share It :
  • Print
  • email
  • PDF
  • Google Bookmarks
  • Facebook
  • Twitter
  • MySpace
  • Yahoo! Buzz
  • del.icio.us
  • Digg
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Reddit
  • Technorati
  • Design Float
  • RSS

Related posts:

  1. How To Display Only Specific Category In Search Results
  2. How to Add Google +1 Button To WordPress
  3. A simple CSS based usability tip for search buttons
  4. How To Add The Tumblr Share Button In WordPress
  5. Fix Visual Editor In WordPress

Comments are closed.