Enlight search results in your WordPress blog


/ Published in: PHP
Save to your folder(s)

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; }


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.