Posted By

newsok on 10/26/10


Tagged

search wordpress highlight


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

booski


Enlight search results in your WordPress blog


 / Published in: PHP
 

Open your search.php file and find the the_title() function. Replace it with the following:

1.echo $title;

Save the search.php file and open style.css. Append the following line to it: strong.search-excerpt { background: yellow; }

  1. <?php
  2. $title = get_the_title();
  3. $keys= explode(" ",$s);
  4. $title = preg_replace('/('.implode('|', $keys) .')/iu',
  5. '<strong class="search-excerpt">\0</strong>',
  6. $title);
  7. ?>

Report this snippet  

You need to login to post a comment.