<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WpFunc &#187; highlight</title>
	<atom:link href="http://wpfunc.com/tag/highlight/feed" rel="self" type="application/rss+xml" />
	<link>http://wpfunc.com</link>
	<description>Awesome, Quick, Simple WordPress Functions!</description>
	<lastBuildDate>Thu, 01 Dec 2011 01:17:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Highlight the Searched Text!</title>
		<link>http://wpfunc.com/wordpress/highlight-the-searched-text.html</link>
		<comments>http://wpfunc.com/wordpress/highlight-the-searched-text.html#comments</comments>
		<pubDate>Tue, 22 Sep 2009 19:59:47 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[header.php]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[highlight searched text]]></category>
		<category><![CDATA[search term]]></category>
		<category><![CDATA[search terms]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=202</guid>
		<description><![CDATA[Some themes have a highlighted search page, some themes don&#8217;t have this page too. But i will give some code to you. With this code you can highlight the searched text on your theme. This function may help your users when they search any important things. Lets Begin..

Here is the code;
First make a backup functions.php [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Some themes have a highlighted search page, some themes don&#8217;t have this page too. But i will give some code to you. With this code you can highlight the searched text on your theme. This function may help your users when they search any important things. Lets Begin..<span id="more-202"></span></p>
<p style="text-align: justify;"><span class="attention">We will change our theme&#8217;s <strong>function.php</strong> and <strong>header.php</strong>. If you don&#8217;t know about WordPress coding or PHP please don&#8217;t touch this files. If you wanna help send me e-mail about this function.</span></p>
<h3 style="text-align: justify;">Here is the code;</h3>
<p style="text-align: justify;">First make a backup functions.php and header.php (These files under the your themes path [<strong>wp-content/theme/your-theme</strong>]). After backup, you can change this files and you can send them to your server.</p>
<p style="text-align: justify;">Insert this code into <strong>theme&#8217;s Functions.php</strong>:</p>
<pre class="brush: plain; title: ; notranslate">function hls_set_query() {
  $query  = attribute_escape(get_search_query());

  if(strlen($query) &gt; 0){
    echo '
      &lt;script type=&quot;text/javascript&quot;&gt;
        var hls_query  = &quot;'.$query.'&quot;;
      &lt;/script&gt;
    ';
  }
}

function hls_init_jquery() {
  wp_enqueue_script('jquery');
}

add_action('init', 'hls_init_jquery');
add_action('wp_print_scripts', 'hls_set_query');
</pre>
<p style="text-align: justify;">And after that, Open your <strong>theme&#8217;s header.php</strong> and paste this code before <strong>&lt;/head&gt;</strong> tag.</p>
<pre class="brush: plain; title: ; notranslate">&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
    .hls { background: #D3E18A; }
  &lt;/style&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  jQuery.fn.extend({
    highlight: function(search, insensitive, hls_class){
      var regex = new RegExp(&quot;(&lt;[^&gt;]*&gt;)|(\\b&quot;+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,&quot;\\$1&quot;) +&quot;)&quot;, insensitive ? &quot;ig&quot; : &quot;g&quot;);
      return this.html(this.html().replace(regex, function(a, b, c){
        return (a.charAt(0) == &quot;&lt;&quot;) ? a : &quot;&lt;strong class=\&quot;&quot;+ hls_class +&quot;\&quot;&gt;&quot; + c + &quot;&lt;/strong&gt;&quot;;
      }));
    }
  });
  jQuery(document).ready(function($){
    if(typeof(hls_query) != 'undefined'){
      $(&quot;#post-area&quot;).highlight(hls_query, 1, &quot;hls&quot;);
    }
  });
  &lt;/script&gt;
</pre>
<p style="text-align: justify;">After that you can send files to your server. When you search you can see searched texts are highlighted!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/highlight-the-searched-text.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Highlight Searched Text In Results</title>
		<link>http://wpfunc.com/wordpress/how-to-highlight-searched-text-in-results.html</link>
		<comments>http://wpfunc.com/wordpress/how-to-highlight-searched-text-in-results.html#comments</comments>
		<pubDate>Tue, 21 Jul 2009 12:00:43 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[searched text]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=76</guid>
		<description><![CDATA[You can highlight searched text in search results. WordPress search system is powerfull but some things not acceptable for me :) i searched on internet and found this code for theme developers. You can add this special code to your theme. You need to change serach.php and your style.css.First open your search.php with your favourite [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">You can highlight searched text in search results. WordPress search system is powerfull but some things not acceptable for me :) i searched on internet and found this code for theme developers. You can add this special code to your theme. You need to change serach.php and your style.css.<span id="more-76"></span>First open your search.php with your favourite php editor;</p>
<p>Find the_title() function and replace with</p>
<pre class="brush: plain; title: ; notranslate">echo $title;</pre>
<p>After than add this code to before modified line</p>
<pre class="brush: plain; title: ; notranslate">&lt;?php
 $title  = get_the_title();
 $keys= explode(&quot; &quot;,$s);
 $title  = preg_replace('/('.implode('|', $keys) .')/iu',
 '&lt;strong class=&quot;search-excerpt&quot;&gt;\0&lt;/strong&gt;',  $title);
?&gt;</pre>
<p>And Last Step :)</p>
<p>Add this line to your style.css</p>
<pre class="brush: plain; title: ; notranslate">strong.search-excerpt { background: yellow; }</pre>
<p>You can change &#8216;yellow&#8217; with a color code or color name.</p>
<p>That&#8217;s All! Have a nice day!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/how-to-highlight-searched-text-in-results.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

