<?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>bavotasan.com &#187; piece</title>
	<atom:link href="http://bavotasan.com/tag/piece/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Use jQuery to Replace a Word with a Link</title>
		<link>http://bavotasan.com/2010/jquery-replace-word-with-link/</link>
		<comments>http://bavotasan.com/2010/jquery-replace-word-with-link/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 20:54:46 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2615</guid>
		<description><![CDATA[If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all [...]]]></description>
			<content:encoded><![CDATA[<p>If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all it took was a small piece of code. </p>
<p>If you don&#8217;t already have jQuery loaded into your page, include this before your closing <code>&lt;head&gt;</code>.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>That will load up jQuery from Google.</p>
<p>Now you just need to include this in your site&#8217;s footer, before the closing <code>&lt;body&gt;</code>. (Why in the footer? Because including your JavaScript after all of your code is the efficient way to do it.)</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> thePage <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/jQuery/ig</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;a href=&quot;http://jquery.com&quot;&gt;jQuery&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Since jQuery doesn&#8217;t have a core function for replacing text, we will use the JavaScript <code><a href="http://www.w3schools.com/jsref/jsref_replace.asp">replace()</a></code> function. The <code>i</code> after the slash makes the search and replace case-insensitive, and the <code>g</code> makes it global. </p>
<p>I have the script working on this page to replace every instance of the word jQuery with a link to the jQuery Web site.</p>
<p><script type="text/javascript">
(function($) {
  $(".posttop p").each(function() {
    $(this).html($(this).html().replace(/jQuery/ig, '<a href="http://jquery.com">jQuery</a>')); 
  });
})(jQuery)
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/jquery-replace-word-with-link/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Excluding Pages from WordPress Search</title>
		<link>http://bavotasan.com/2010/excluding-pages-from-wordpress-search/</link>
		<comments>http://bavotasan.com/2010/excluding-pages-from-wordpress-search/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 20:05:18 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[Search Query]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2508</guid>
		<description><![CDATA[When people visit my site and do a search, I assume they&#8217;re looking for results within my posts and not in any of my static pages. Too bad WordPress automatically searches through both. In order to exclude pages from the WordPress search, you need to add a small piece of code to the functions.php file. [...]]]></description>
			<content:encoded><![CDATA[<p>When people visit my site and do a search, I assume they&#8217;re looking for results within my posts and not in any of my static pages. Too bad WordPress automatically searches through both. In order to exclude pages from the WordPress search, you need to add a small piece of code to the <code>functions.php</code> file. I found a solution on <a href="http://www.wprecipes.com/how-to-exclude-posts-or-pages-from-search-results">WP Recipes</a> but I was not a fan of having to add all of my category IDs in order to make it work. So I decided to modify it a bit.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> SearchFilter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_search</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_type'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'SearchFilter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>I forced it to just search for posts through setting the <code>post_type</code>. You can also make it do the opposite by setting the <code>post_type</code> to page.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/excluding-pages-from-wordpress-search/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Quick Function to Shorten the Post Title in WordPress</title>
		<link>http://bavotasan.com/2010/quick-function-shorten-post-title-wordpress/</link>
		<comments>http://bavotasan.com/2010/quick-function-shorten-post-title-wordpress/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 20:46:16 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[need]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[pop]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[reason]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1881</guid>
		<description><![CDATA[For some reason, a lot of people seem to be using extremely long post titles. I am a firm believer in making a title as precise as possible to make it easier on people who are trying to actually find your article. Sure, I guess you can throw in as many keywords as you want [...]]]></description>
			<content:encoded><![CDATA[<p>For some reason, a lot of people seem to be using extremely long post titles. I am a firm believer in making a title as precise as possible to make it easier on people who are trying to actually find your article. Sure, I guess you can throw in as many keywords as you want in hopes that you might get more from Google, but I doubt that will really do anything for your site&#8217;s SEO.<br />
<span id="more-1881"></span><br />
In case you are one of those people who feel the need for extremely long post titles and you want to display them in places where they might not fit, here is a quick piece of code that you can add to your <code>functions.php</code> file.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> short_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$after</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$after</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$mytitle</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>You can call the function like so:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">// short_title($after, $length)</span>
<span style="color: #b1b100;">echo</span> short_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'...'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>The above code will truncate your title at 10 words and add a trailing ellipsis.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/quick-function-shorten-post-title-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Force WordPress to use the Latest Version of jQuery</title>
		<link>http://bavotasan.com/2010/force-wordpress-use-latest-version-jquery/</link>
		<comments>http://bavotasan.com/2010/force-wordpress-use-latest-version-jquery/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 15:20:43 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Change]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[Place]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1875</guid>
		<description><![CDATA[If you&#8217;re using WordPress 2.9.x, then the latest version of jQuery included is 1.3.2. What if you want to take advantage of new features in version 1.4, like delaying an animation queue or binding multiple event handlers? You can easily add a link in your header to the latest version, but that might end up [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using WordPress 2.9.x, then the latest version of <a href="http://jquery.com/">jQuery</a> included is 1.3.2. What if you want to take advantage of new features in version 1.4, like delaying an animation queue or binding multiple event handlers? You can easily add a link in your header to the latest version, but that might end up conflicting with some plugins or themes.<br />
<span id="more-1875"></span><br />
The best approach would be to use the following piece of code to let WordPress know that you want to load the current version instead.</p>
<p>Place this into your theme&#8217;s <code>functions.php</code> file:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> current_jquery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$version</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_scripts</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$version</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp_scripts</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">registered</span><span style="color: #009900;">&#91;</span>jquery<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">ver</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                wp_deregister_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                wp_register_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'http://ajax.googleapis.com/ajax/libs/jquery/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$version</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/jquery.min.js'</span><span style="color: #339933;">,</span>
                        <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$version</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> current_jquery<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'1.4.2'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change number to latest version</span></pre></div></td></tr></table></div>

<p>If jQuery is updated, all you have to do is change the version number when calling the function.</p>
<p><strong>Reference</strong>: <a href="http://binarybonsai.com/2010/02/14/how-to-load-the-latest-jquery-in-wordpress/">Binary Bonsai</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/force-wordpress-use-latest-version-jquery/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Using jQuery for a Simple Animated Fade Effect</title>
		<link>http://bavotasan.com/2010/jquery-simple-animated-fade-effect/</link>
		<comments>http://bavotasan.com/2010/jquery-simple-animated-fade-effect/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:57:26 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[person]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1817</guid>
		<description><![CDATA[I know I have already done a fade effect between two images with jQuery, but here is a quick little piece of code that will just add a nice animated fade effect to single images. Whenever a person hovers over an image, we will use jQuery to lower the opacity to make it appear lighter. [...]]]></description>
			<content:encoded><![CDATA[<p>I know I have already done a fade effect between two images with jQuery, but here is a quick little piece of code that will just add a nice animated fade effect to single images. Whenever a person hovers over an image, we will use jQuery to lower the opacity to make it appear lighter. Easy and not that impressive but still pretty cool.<br />
<span id="more-1817"></span><br />
Make sure you first call jQuery.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">'jquery.js'</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Then just add the following code and all your images will have a slight fade when you hover over them.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0.8&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>If you only want this to occur on certain images than just make sure to change the first jQuery selector to the class name of the images your want this effect to affect.</p>
<p>Try it out below:</p>
<p><script type="text/javascript">
  jQuery(document).ready(function(){
    jQuery("img.opacity").hover(function() {
      jQuery(this).stop().animate({opacity: "0.8"}, 'slow');
    },
    function() {
      jQuery(this).stop().animate({opacity: "1"}, 'slow');
    });
  });
</script></p>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/09/jquerylogo.png" alt="" title="" width="200" height="150" class="alignleft opacity" /><img src="http://bavotasan.com/wp-content/uploads/2009/07/jquery.png" title="" alt="" width="200" height="150" class="alignleft opacity" /></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/jquery-simple-animated-fade-effect/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Find the Category ID using the Category Slug in WordPress</title>
		<link>http://bavotasan.com/2009/find-the-category-id-using-the-category-slug-in-wordpress/</link>
		<comments>http://bavotasan.com/2009/find-the-category-id-using-the-category-slug-in-wordpress/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 17:40:52 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[category id]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[name]]></category>
		<category><![CDATA[none]]></category>
		<category><![CDATA[OBJECT]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[slug]]></category>
		<category><![CDATA[something]]></category>
		<category><![CDATA[use]]></category>
		<category><![CDATA[value]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1610</guid>
		<description><![CDATA[This is a quick little piece of code that I have been using a lot lately. I needed to get the category ID but all I had to work with was the category slug. Luckily WordPress has a neat little function called get_term_by() which makes it super easy. The function can be used to get [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick little piece of code that I have been using a lot lately. I needed to get the category ID but all I had to work with was the category slug. Luckily WordPress has a neat little function called <code>get_term_by()</code> which makes it super easy. The function can be used to get a lot more information but for this example I am just going to extract the ID.<br />
<span id="more-1610"></span><br />
The function works like this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_term_by<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$taxonomy</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p><strong>$field</strong>: (string) (required) Either &#8216;slug&#8217;, &#8216;name&#8217;, or &#8216;id&#8217;. Default: None<br />
<strong>$value</strong>: (string|integer) (required) Search for this term value. Default: None<br />
<strong>$taxonomy</strong>: (string) (required) Taxonomy Name. Default: None<br />
<strong>$output</strong>: (string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N. Default: OBJECT<br />
<strong>$filter</strong>: (string) (optional) default is raw or no WordPress defined filter will applied. Default: &#8216;raw&#8217; </p>
<p>We are going to use it like this to get the ID with the category slug &#8216;tutorials&#8217;:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$theCatId</span> <span style="color: #339933;">=</span> get_term_by<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'slug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tutorials'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$theCatId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$theCatId</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>If you insert a <code>print_r()</code> function you can echo out all the information that the <code>get_term_by()</code> function contains. Use something like this and see if there is other information that you might want to extract:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$theCatId</span> <span style="color: #339933;">=</span> get_term_by<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'slug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tutorials'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theCatId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>Then all you would have to do is use whichever term your see between those square brackets like so:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$theCatId</span> <span style="color: #339933;">=</span> get_term_by<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'slug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tutorials'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$theCatId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$theCatId</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">description</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/find-the-category-id-using-the-category-slug-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Using PHP to Remove an HTML Tag from a String</title>
		<link>http://bavotasan.com/2009/using-php-to-remove-an-html-tag-from-a-string/</link>
		<comments>http://bavotasan.com/2009/using-php-to-remove-an-html-tag-from-a-string/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:54:49 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Image Tag]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Php Function]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[Preg]]></category>
		<category><![CDATA[Remove]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[way]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1555</guid>
		<description><![CDATA[There are times when you need to strip one specific HTML tag from a string and the PHP function strip_tags() doesn&#8217;t work the way you want it to. strip_tags() allows for certain exclusions, but why would you use that when you only want to exclude one tag and include all other tags? Especially when you [...]]]></description>
			<content:encoded><![CDATA[<p>There are times when you need to strip one specific HTML tag from a string and the PHP function <code>strip_tags()</code> doesn&#8217;t work the way you want it to.  <code>strip_tags()</code> allows for certain exclusions, but why would you use that when you only want to exclude one tag and include all other tags? Especially when you can use <code>preg_replace()</code>.<br />
<span id="more-1555"></span><br />
Here is a quick little piece of code that can be modified for any specific HTML tag you want to remove from a string. I am using it below to remove an image tag.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Here is your content with an image tag &lt;img src=&quot;http://bavotasan.com/wp-content/themes/bavotasan_new/images/bavota.png&quot; alt=&quot;Image&quot; /&gt;'</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&lt;img[^&gt;]+\&gt;/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$string</span> <span style="color: #666666; font-style: italic;">// will output &quot;Here is your content with an image tag&quot; without the image tag</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>You can replace the <code>img</code> in the <code>preg_replace()</code> function for it to work with whichever HTML tag you wish.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/using-php-to-remove-an-html-tag-from-a-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quick &amp; Easy Excerpt Mods Coming in WordPress 2.9</title>
		<link>http://bavotasan.com/2009/quick-easy-excerpt-mods-coming-in-wordpress-2-9/</link>
		<comments>http://bavotasan.com/2009/quick-easy-excerpt-mods-coming-in-wordpress-2-9/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 15:14:55 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Change]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[end]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[mods]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[power]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[the_excerpt]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1393</guid>
		<description><![CDATA[I just stumbled across these two little pieces of code and thought that they might be useful to some people out there who want to mess around with the default settings for the_excerpt() function in WordPress. The first one gives you the power to change the number of words displayed by the function the_excerpt(), and [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across these two little pieces of code and thought that they might be useful to some people out there who want to mess around with the default settings for <code>the_excerpt()</code> function in WordPress. The first one gives you the power to change the number of words displayed by the function <code>the_excerpt()</code>, and yes, you can have more than 55 words. The second piece of code allows you to change the trailing [...] that appears at the end of your excerpt.<br />
<span id="more-1393"></span><br />
Both features are set to be added to version 2.9 of WordPress, but the first currently works in version 2.8.5. Just add these to your theme&#8217;s functions.php file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> new_excerpt_length<span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'excerpt_length'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_excerpt_length'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Change the number &#8220;20&#8243; to whatever number you want.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> new_excerpt_more<span style="color: #009900;">&#40;</span><span style="color: #000088;">$more</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'[.....]'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'excerpt_more'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_excerpt_more'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Change &#8220;[.....]&#8221; to whatever you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/quick-easy-excerpt-mods-coming-in-wordpress-2-9/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Turn Plain Text URLs into Active Links using PHP</title>
		<link>http://bavotasan.com/2009/turn-plain-text-urls-into-active-links-using-php/</link>
		<comments>http://bavotasan.com/2009/turn-plain-text-urls-into-active-links-using-php/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 16:02:22 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[Anchor Tag]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[com]]></category>
		<category><![CDATA[everything]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[Space]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[way]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=983</guid>
		<description><![CDATA[I was putting together a bit of code to pull in a Twitter feed, similar to what you see in the footer of bavotasan.com. I got everything working properly but the only problem was all of the URLs were just plain text instead of active links. I figured out a way to automatically turn the [...]]]></description>
			<content:encoded><![CDATA[<p>I was putting together a bit of code to pull in a Twitter feed, similar to what you see in the footer of bavotasan.com. I got everything working properly but the only problem was all of the URLs were just plain text instead of active links. I figured out a way to automatically turn the URLs into active links using a small piece of PHP.<br />
<span id="more-983"></span></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ereg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[[:alpha:]]+://[^&lt;&gt;[:space:]]+[[:alnum:]/]&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>0<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #000099; font-weight: bold;">\\</span>0&lt;/a&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>The code finds all instances of <code>http://</code> and converts the string into an active link by surrounding it with an anchor tag.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/turn-plain-text-urls-into-active-links-using-php/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Check if a Number is Even or Odd with PHP</title>
		<link>http://bavotasan.com/2009/check-if-a-number-is-even-or-odd-with-php/</link>
		<comments>http://bavotasan.com/2009/check-if-a-number-is-even-or-odd-with-php/#comments</comments>
		<pubDate>Thu, 07 May 2009 20:52:21 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=573</guid>
		<description><![CDATA[Ever needed to check if a number is even or odd? If so, here is a pretty simple piece of code that does just that. &#60;?php $num = 13; if&#40;$num&#38;1&#41; &#123; echo 'The number is odd.'; &#125; else &#123; echo 'The number is even.'; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Ever needed to check if a number is even or odd? If so, here is a pretty simple piece of code that does just that.<br />
<span id="more-573"></span></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #339933;">&amp;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'The number is odd.'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'The number is even.'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/check-if-a-number-is-even-or-odd-with-php/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

