/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<div class="post"> <?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt-title">\0</strong>', $title); ?> <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php echo $title; ?></a></h2> <p class="post-meta"> <!-- <span class="comments"><?php comments_popup_link(__('0 Comments', 'woothemes'), __('1 Comment', 'woothemes'), __('% Comments', 'woothemes')); ?></span> --> </p> <div class="entry"> <!-- Search Term Highlighting in the excerpt --> <?php $excerpt = get_the_excerpt(); $keys= explode(" ",$s); $excerpt = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $excerpt); ?> <?php echo $excerpt; ?> </div><!-- /.entry -->