<?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>WP Engineer &#187; filter_hook</title>
	<atom:link href="http://wpengineer.com/tag/filter_hook/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Highlight A Slogan In WordPress</title>
		<link>http://wpengineer.com/195/how-to-highlight-a-slogan-in-wordpress/</link>
		<comments>http://wpengineer.com/195/how-to-highlight-a-slogan-in-wordpress/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 18:26:51 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[filter_hook]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=195</guid>
		<description><![CDATA[In this example I'm talking about how to display a specific company slogan in a certain color. This slogan is found in the header and content. Of course my client doesn't want to put in span class="foo" every time. This is what it should look like: Therefor I have to write a function. First I [...]]]></description>
			<content:encoded><![CDATA[<p>In this example I'm talking about how to display a specific company slogan in a certain color. This slogan is found in the header and content.</p>
<p>Of course my client doesn't want to put in <code>span class="foo"</code> every time. This is what it should look like:<br />
<span id="more-195"></span><br />
<img src="http://wpengineer.com/wp-content/uploads/colorize-title.jpg" alt="highligt a slogan in WordPress" title="highligt a slogan in WordPress" width="300" height="200" class="size-full wp-image-196" /></p>
<p>Therefor I have to write a function. First I have to search for the string "by *FOO" and wrap a span around "by" as well as around "*FOO", since it is also displayed without "by". If I added it to the first function "*FOO" which already has a span would get an additional span. Here is the code:</p>
<pre lang="php">
function colorize_FOO($content) {
	$str = &quot;*FOO&quot;;
	$newstr = &quot;&lt;span class=\&quot;foo\&quot;&gt;*FOO&lt;/span&gt;&quot;;
	$html = str_replace($str, $newstr, $content);
	return $html;
}
function colorize_by($content) {
	$str = &quot;by *FOO&quot;;
	$newstr = &quot;&lt;span class=\&quot;by\&quot;&gt;by&lt;/span&gt; *FOO&quot;;
	$html = str_replace($str, $newstr, $content);
	return $html;
}

add_filter(&#039;the_title&#039;, &#039;colorize_by&#039;,1);
add_filter(&#039;the_content&#039;, &#039;colorize_by&#039;,1);
add_filter(&#039;the_title&#039;, &#039;colorize_FOO&#039;,1);
add_filter(&#039;the_content&#039;, &#039;colorize_FOO&#039;,1);
</pre>
<p>Sure there are more elegant methods, but a better one didn't come in my mind so quickly <img src='http://wpengineer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/195/how-to-highlight-a-slogan-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

