<?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>WordPress Freelancer &#187; PHP</title>
	<atom:link href="http://www.wplancer.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wplancer.com</link>
	<description>WordPress Freelance Designer &#38; Developer</description>
	<lastBuildDate>Mon, 08 Feb 2010 22:33:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Easy PHP II: Variables</title>
		<link>http://www.wplancer.com/easy-php-ii-variables/</link>
		<comments>http://www.wplancer.com/easy-php-ii-variables/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 21:58:50 +0000</pubDate>
		<dc:creator>BANAGO</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.wplancer.com/?p=986</guid>
		<description><![CDATA[In the previous <a title="PHP Introductin" href="http://www.wplancer.com/easy-php-i-introduction/">introductory PHP tutorial</a> we talked about what PHP looks like and in what kind of environment it runs. To sum up, we said that we write PHP code between tags that look like this: “<em>&#60;?php … ?&#62;</em>” and we end every command line must and in semicolon (<em>;</em>). We use “<em>echo</em>” or “<em>print</em>” in order for PHP to show things to us.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 15px 10px 0 0;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wplancer.com%2Feasy-php-ii-variables%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wplancer.com%2Feasy-php-ii-variables%2F&amp;source=banago&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><strong><a href="http://www.wplancer.com/wp-content/tux-php-variables.jpeg"><img class="size-medium wp-image-990 alignright" title="tux-php-variables" src="http://www.wplancer.com/wp-content/tux-php-variables-249x249.jpg" alt="" width="249" height="249" /></a></strong>In the previous <a title="PHP Introductin" href="http://www.wplancer.com/easy-php-i-introduction/">introductory PHP tutorial</a> we talked about what PHP looks like and in what kind of environment it runs. To sum up, we said that we write PHP code between tags that look like this: “<em>&lt;?php … ?&gt;</em>” and we end every command line must and in semicolon (<em>;</em>). We use “<em>echo</em>” or “<em>print</em>” in order for PHP to show things to us. We also said that we need to have Apache server, PHP and MySQL installed in our computer or server so that PHP can run and we concluded that using a ready-made package like XAMPP, WAMP, or MAMP to achieve that would be optimal. Today we are going to learn about PHP variables, their kinds and use.</p>
<h3>What are Variables</h3>
<p>Here is what a variable looks like:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">// Our first variable
</span>
$cool_variable <span class="phpOperator">=</span> <span class="phpString">'This s a really cool variable'</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Variables are used to hold some value or data for a certain time so that you can use it when you need it later in your code. Variables start with a dollar sign ($).  A variable name must start with a letter or an underscore &#8220;_&#8221; .  A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )  and should not contain spaces. When a variable name is made of more than one word, it can be separated with an underscore ($cool_variable), or written in camel case ($coolVariable).  Variables can hold data of different types.</p>
<p><strong>PHP Variables Data Types</strong></p>
<p>There are four PHP variables data types. Let&#8217;s deduce them by example:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$first_type <span class="phpOperator">=</span> <span class="phpString">'This a cool text variable'</span><span class="phpText">;</span> <span class="phpComment">// Just text.
</span>
$second_type <span class="phpOperator">=</span> 123; <span class="phpComment">// Just a number – note the lack of quotes<span class="phpOperator">.</span>
</span>
$third_type <span class="phpOperator">=</span> <span class="phpNumber">1</span><span class="phpOperator">.</span>23; <span class="phpComment">// Decimal number – note the lack of quotes<span class="phpOperator">.</span>
</span>
$fourth_type <span class="phpOperator">=</span> <span class="phpString">' '</span><span class="phpText">;</span> <span class="phpComment">// Just empty  - cool, isn&#039;t it.
</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>As you can see in above examples, declaring any type of variable is very easy. Every type has a name and they are respectively called: 1. <strong>String</strong>, 2. <strong>Integer</strong>, 3. <strong>Float</strong>, 4. <strong>Boolean</strong>. We don&#8217;t need to tell PHP which data type is variable holding; PHP evaluates the data when you assign it to the variable and then stores it as the appropriate type. Let&#8217;s talk about them in detail.</p>
<ul>
<li><strong>String: </strong>A 	series of characters, otherwise called text. There is no practical 	limit on the length of a string or text. A string must be written 	between double or single quotes, otherwise PHP will produce an 	error.</li>
<li><strong>Integer</strong>: 	A whole number (no fractions), such as –43, 0, 1, 27, or 5438. 	Integer numbers should not be wrapped with quotes, otherwise they 	will be considered as a string, not an integer i.e. text and not 	number.</li>
<li><strong>Float</strong>: A 	number (usually not a whole number) that includes decimal places, 	such as 5.24 or 123.456789. This is often called a real number or a 	float. A float should not be wrapped with quotes too.</li>
<li><strong>Boolean</strong>: 	A TRUE or FALSE value. Boolean data types represent two possible 	states — TRUE or FALSE. A FALSE boolean is declared 	in several ways  &#8211; at the example above we saw only one of them. 	Here is the whole list:
<ul>
<li>The string 		<em>FALSE</em> (can be upper- or lowercase)</li>
<li>The integer 0</li>
<li>The float 0.0</li>
<li>An empty 		string (as in the example above)</li>
<li>The 		one-character string &#8217;0&#8242;</li>
<li>The constant 		NULL</li>
</ul>
<p>On the other hand, 	any other values in a Boolean variable are considered 	TRUE. If you echo a Boolean variable, the value FALSE displays as a 	blank string; the value TRUE echoes as a 1.</li>
</ul>
<p><strong>Assigning data to variables</strong></p>
<p>The equals sign we used in the above statements is called the <strong><em>assignment operator</em></strong>, as it is used to assign values to variables.  There are a ton other <strong><em>PHP operators</em></strong> that we need to know in order to be successful PHP programmers and we will talk about them in our next tutorial <em>PHP Operators</em>, so stay tuned.</p>
<p><strong>Further Readings:</strong></p>
<ol>
<li>Understanding 	PHP Data Types: 	<a href="http://eu.dummies.com/WileyCDA/how-to/content/understanding-php-data-types.html#ixzz0eONIuWQ5">http://eu.dummies.com/WileyCDA/how-to/content/understanding-php-data-types.html</a></li>
<li>PHP 	Variables: <a href="http://www.w3schools.com/PHP/php_variables.asp">http://www.w3schools.com/PHP/php_variables.asp</a></li>
<li>What 	is a Variable: <a href="http://www.homeandlearn.co.uk/php/php2p1.html">http://www.homeandlearn.co.uk/php/php2p1.html</a></li>
<li>Learn 	PHP from Scratch: 	<a href="http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/">http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.wplancer.com/easy-php-ii-variables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Limit Content in WordPress</title>
		<link>http://www.wplancer.com/how-to-limit-content-in-wordpress/</link>
		<comments>http://www.wplancer.com/how-to-limit-content-in-wordpress/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 14:31:14 +0000</pubDate>
		<dc:creator>BANAGO</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.wplancer.com/?p=905</guid>
		<description><![CDATA[Have you seen those cool magazine style WordPress themes around this days? They are just cool. You might have noticed that they sometimes show a few words of the post, this is for sure not the default WordPress excerpt showing that because the default excerpt length is set to 55 words and manually excerpting every post would be a great time consumer. So, what are this guys putting together to get that cool effect on their sites by controlling the length of the content?]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 15px 10px 0 0;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wplancer.com%2Fhow-to-limit-content-in-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wplancer.com%2Fhow-to-limit-content-in-wordpress%2F&amp;source=banago&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.wplancer.com/wp-content/wordpress-limit-content.png"><img class="size-medium wp-image-963 alignright" title="wordpress-limit-content" src="http://www.wplancer.com/wp-content/wordpress-limit-content-250x250.png" alt="" width="250" height="250" /></a>Have you seen those cool magazine style WordPress themes around this days? They are just cool. You might have noticed that they sometimes show a few words of the post, this is for sure not the default <a title="WordPress Excerpt" href="http://codex.wordpress.org/Template_Tags/the_excerpt">WordPress excerpt</a> showing that because the default excerpt length is set to 55 words and manually excerpting every post would be a great time consumer. So, what are this guys putting together to get that cool effect on their sites by controlling the length of the content? Well, as a <a title="WordPress Freelancer" href="http://www.wplancer.com/wordpress-freelance-services/">WordPress freelancer</a>, I have been needing that feature myself and today I&#8217;m going to share with you how to have that feature on your site.</p>
<p>There are three different approaches to limit your excerpt or content in WordPress that you must know:</p>
<h3>1. WordPress&#8217;s Approach</h3>
<p>WordPress developers have provided us lately with a tool to limit the excerpt. I do not use it myself as I&#8217;m more conformable with another approach as I find this a little limited. To change excerpt length using the default WordPress excerpt limit approach you have to use the <a title="Plugin API/Filter Reference/excerpt length" href="http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length">excerpt_length</a> filter and add the following code to <em>functions.php</em> file in your theme:</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> new_excerpt_length<span class="phpOperator">(</span>$length<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
return </span>20;
<span class="phpOperator">}</span>
add_filter<span class="phpOperator">(</span><span class="phpString">'excerpt_length'</span>, <span class="phpString">'new_excerpt_length'</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>Every time you will use <em>the_excerpt();</em> on your code it will output an 20-word text string for you. Right now you&#8217;ve got a question, don&#8217;t you? I know, I had it too. The question is: What if I want to use the 20-word excerpt in some places on my theme, but still be able to use the 55-word one? Or just have two or three different-length exerts to use on my theme? Well, if that is the case, the default approach is not for you, so continue reading.</p>
<h3>2. StudioPress&#8217;s Approach</h3>
<p>I don&#8217;t really know who came up with this approach originally, but I know that the guys over at <a title="StudioPress" href="http://www.studiopress.com">StudioPress</a> use it on their themes. This function is called <em>the_content_limit().</em> This is how the code that will go into the <em>functions.php</em> file looks like &#8211; lengthy huh?</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> the_content_limit<span class="phpOperator">(</span>$max_char, $more_link_text <span class="phpOperator">=</span> <span class="phpString">'<span class="phpOperator">(</span>more.<span class="phpOperator">.</span>.<span class="phpOperator">)</span>'</span>, $stripteaser <span class="phpOperator">=</span> <span class="phpNumber">0</span>, $more_file <span class="phpOperator">=</span> <span class="phpString">''</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
$content <span class="phpOperator">=</span> get_the_content<span class="phpOperator">(</span>$more_link_text, $stripteaser, $more_file<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> apply_filters<span class="phpOperator">(</span><span class="phpString">'the_content'</span>, $content<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">]</span><span class="phpOperator">]</span><span class="phpOperator">&gt;</span>'</span>, <span class="phpString">'<span class="phpOperator">]</span><span class="phpOperator">]</span><span class="phpOperator">&gt;</span>'</span>, $content<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">strip_tags</span><span class="phpOperator">(</span>$content<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpFunction">strlen</span><span class="phpOperator">(</span><span class="phpScriptVar">$_GET</span><span class="phpOperator">[</span><span class="phpString">'p'</span><span class="phpOperator">]</span><span class="phpOperator">)</span> <span class="phpOperator">&gt;</span> <span class="phpNumber">0</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpFunction">echo</span> <span class="phpString">"<span class="phpOperator">&lt;</span>p<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $content;
<span class="phpFunction">echo</span> <span class="phpString">"&#038;nbsp<span class="phpText">;</span><span class="phpOperator">&lt;</span>a href="</span>%22<span class="phpText">;</span><span class="phpString">"<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>
the_permalink<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> "</span><span class="phpString">'<span class="phpOperator">&gt;</span><span class="phpString">"<span class="phpOperator">.</span>"</span>Read More &#038;rarr<span class="phpText">;</span><span class="phpString">"<span class="phpText">;</span>
<span class="phpFunction">echo</span> "</span><span class="phpOperator">&lt;</span>/p<span class="phpOperator">&gt;</span><span class="phpString">"<span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
else </span>>if </span><span class="phpOperator">(</span><span class="phpOperator">(</span><span class="phpFunction">strlen</span><span class="phpOperator">(</span>$content<span class="phpOperator">)</span><span class="phpOperator">&gt;</span>$max_char<span class="phpOperator">)</span> &#038;amp<span class="phpText">;</span>&#038;amp<span class="phpText">;</span> <span class="phpOperator">(</span>$espacio <span class="phpOperator">=</span> <span class="phpFunction">strpos</span><span class="phpOperator">(</span>$content, "</span> <span class="phpString">", $max_char <span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">substr</span><span class="phpOperator">(</span>$content, <span class="phpNumber">0</span>, $espacio<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> $content;
<span class="phpFunction">echo</span> "</span><span class="phpOperator">&lt;</span>p<span class="phpOperator">&gt;</span><span class="phpString">"<span class="phpText">;</span>
<span class="phpFunction">echo</span> $content;
<span class="phpFunction">echo</span> "</span>.<span class="phpOperator">.</span>.<span class="phpString">"<span class="phpText">;</span>
<span class="phpFunction">echo</span> "</span>&#038;nbsp<span class="phpText">;</span><span class="phpOperator">&lt;</span>a href=<span class="phpString">"%22<span class="phpText">;</span>"</span><span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>
the_permalink<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> <span class="phpString">"'</span><span class="phpOperator">&gt;</span>".$more_link_text.<span class="phpString">"<span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> <span class="phpString">"<span class="phpOperator">&lt;</span>/p<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
else </span><span class="phpOperator">{</span>
<span class="phpFunction">echo</span> <span class="phpString">"<span class="phpOperator">&lt;</span>p<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $content;
<span class="phpFunction">echo</span> <span class="phpString">"&#038;nbsp<span class="phpText">;</span><span class="phpOperator">&lt;</span>a href="</span>%22<span class="phpText">;</span><span class="phpString">"<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>
the_permalink<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> "</span>&#039;<span class="phpOperator">&gt;</span><span class="phpString">"<span class="phpOperator">.</span>"</span>Read More &#038;rarr<span class="phpText">;</span><span class="phpString">"<span class="phpText">;</span>
<span class="phpFunction">echo</span> "</span><span class="phpOperator">&lt;</span>/p<span class="phpOperator">&gt;</span>&quot;<span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
</pre>
<p>Now we have to call that function because, off course, we are not going to use the default <em>the_excerpt();</em> function. Here:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_content_limit</span><span class="phpOperator">(</span>20, <span class="phpString">"<span class="phpOperator">[</span><span class="htmlText">Read more</span><span class="phpOperator">]</span>"</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Pretty simple to use and offers you the possibility to auto-generate a <em>Read More &#8230; </em>of you choice.</p>
<h3>C.bavota&#8217;s Apprach</h3>
<p>C.bacota &#8211; I don&#8217;t know his real name &#8211; has produced a couple of great code snippets to limit the content for both <em>the_content()</em> and <em>the_excerpt()</em>. As you may already know, <em>the_excerpt()</em> gets 55 words from <em>the_content()</em> but get rids of all the HTML tags on it, be it links, images or whatever. So, this guy produced a script that allows you to choose to use the text-only version or the html-rich version to limitedly display. I find this functions really cool and easy to use and I have been using them ever since they were produced. This is how the block of code that goes into <em>functions.php</em> looks like:</p>
<pre class="php">
<span class="phpComment">// Limit the content to certain number of words<span class="phpOperator">.</span>
</span><span class="phpFunctionKeyword">function</span> excerpt<span class="phpOperator">(</span>$num<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$limit <span class="phpOperator">=</span> $num<span class="phpOperator">+</span><span class="phpNumber">1</span><span class="phpText">;</span>
$excerpt <span class="phpOperator">=</span> <span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">' '</span>, get_the_excerpt<span class="phpOperator">(</span><span class="phpOperator">)</span>, $limit<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">array_pop</span><span class="phpOperator">(</span>$excerpt<span class="phpOperator">)</span><span class="phpText">;</span>
$excerpt <span class="phpOperator">=</span> <span class="phpFunction">implode</span><span class="phpOperator">(</span><span class="phpString">" "</span>,$excerpt<span class="phpOperator">)</span>.<span class="phpString">"<span class="phpOperator">.</span>.<span class="phpOperator">.</span>"</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $excerpt;
<span class="phpOperator">}</span>
<span class="phpComment">// Limit the content to certain number of words<span class="phpOperator">.</span>
</span><span class="phpFunctionKeyword">function</span> content<span class="phpOperator">(</span>$num<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$limit <span class="phpOperator">=</span> $num<span class="phpOperator">+</span><span class="phpNumber">1</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">' '</span>, get_the_content<span class="phpOperator">(</span><span class="phpOperator">)</span>, $limit<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">array_pop</span><span class="phpOperator">(</span>$content<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">implode</span><span class="phpOperator">(</span><span class="phpString">" "</span>,$content<span class="phpOperator">)</span>.<span class="phpString">"<span class="phpOperator">.</span>.<span class="phpOperator">.</span>"</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $content;
<span class="phpOperator">}</span>
</pre>
<p>The above code is quite cool, but has two limitation: The first block of code, will not allow you to have a custom excerpt longer than 55 words, the same as <em>the_excerpt()</em> does, and the second one will bump image into your shorten content if you are using images in the original one. However, Mr. C.Basoda eventually thought about his and <a title="Limit Content or Excerpt" href="http://bavotasan.com/tutorials/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/">produced later a revised version</a> of the code that will allow you to use more than 55 words and not get images on the wrong place there. Here is the revised code:</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> excerpt<span class="phpOperator">(</span>$limit<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$excerpt <span class="phpOperator">=</span> <span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">' '</span>, get_the_excerpt<span class="phpOperator">(</span><span class="phpOperator">)</span>, $limit<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpFunction">count</span><span class="phpOperator">(</span>$excerpt<span class="phpOperator">)</span><span class="phpOperator">&gt;</span><span class="phpOperator">=</span>$limit<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpFunction">array_pop</span><span class="phpOperator">(</span>$excerpt<span class="phpOperator">)</span><span class="phpText">;</span>
$excerpt <span class="phpOperator">=</span> <span class="phpFunction">implode</span><span class="phpOperator">(</span><span class="phpString">" "</span>,$excerpt<span class="phpOperator">)</span>.<span class="phpString">'<span class="phpOperator">.</span>.<span class="phpOperator">.</span>'</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpKeyword"> else </span><span class="phpOperator">{</span>
$excerpt <span class="phpOperator">=</span> <span class="phpFunction">implode</span><span class="phpOperator">(</span><span class="phpString">" "</span>,$excerpt<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
$excerpt <span class="phpOperator">=</span> <span class="phpFunction">preg_replace</span><span class="phpOperator">(</span><span class="phpString">'`\<span class="phpOperator">[</span><span class="phpOperator">[</span>^\<span class="phpOperator">]</span><span class="phpOperator">]</span>*\<span class="phpOperator">]</span>`'</span>,<span class="phpString">''</span>,$excerpt<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
return </span>$excerpt;
<span class="phpOperator">}</span>
<span class="phpFunctionKeyword">function</span> content<span class="phpOperator">(</span>$limit<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">' '</span>, get_the_content<span class="phpOperator">(</span><span class="phpOperator">)</span>, $limit<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpFunction">count</span><span class="phpOperator">(</span>$content<span class="phpOperator">)</span><span class="phpOperator">&gt;</span><span class="phpOperator">=</span>$limit<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpFunction">array_pop</span><span class="phpOperator">(</span>$content<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">implode</span><span class="phpOperator">(</span><span class="phpString">" "</span>,$content<span class="phpOperator">)</span>.<span class="phpString">'<span class="phpOperator">.</span>.<span class="phpOperator">.</span>'</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpKeyword"> else </span><span class="phpOperator">{</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">implode</span><span class="phpOperator">(</span><span class="phpString">" "</span>,$content<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">preg_replace</span><span class="phpOperator">(</span><span class="phpString">'/\<span class="phpOperator">[</span>.<span class="phpOperator">+</span>\<span class="phpOperator">]</span>/'</span>,<span class="phpString">''</span>, $content<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> apply_filters<span class="phpOperator">(</span><span class="phpString">'the_content'</span>, $content<span class="phpOperator">)</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">]</span><span class="phpOperator">]</span><span class="phpOperator">&gt;</span>'</span>, <span class="phpString">'<span class="phpOperator">]</span><span class="phpOperator">]</span><span class="phpOperator">&gt;</span>'</span>, $content<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
return </span>$content;
<span class="phpOperator">}</span>
</pre>
<p>And finally here is how you use this fantastic piece of code:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> excerpt</span><span class="phpOperator">(</span><span class="phpString">'20'</span><span class="phpOperator">)</span><span class="phpText">;</span><span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
// or
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> content</span><span class="phpOperator">(</span><span class="phpString">'20'</span><span class="phpOperator">)</span><span class="phpText">;</span><span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<h3>The end</h3>
<p>We are finally done.  I would also like to make clear that the approaches I presented so far are not necessary all the existing or possible ways to achieve content limitation, however this is what I know and what I thought was of value to share with you. Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wplancer.com/how-to-limit-content-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Easy PHP I: Introduction</title>
		<link>http://www.wplancer.com/easy-php-i-introduction/</link>
		<comments>http://www.wplancer.com/easy-php-i-introduction/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 13:36:19 +0000</pubDate>
		<dc:creator>BANAGO</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.wplancer.com/?p=882</guid>
		<description><![CDATA[I've been involved with PHP since I got into the web design and development world. This is because since in my beginnings I chose to use WordPress as a CMS to build websites with and since that day I have been needing PHP to build WordPress themes (and plug-ins lately). I have learned a lot of PHP tips and tricks, but I have not yet been able to study it regularly and eventually an advanced programmer as I aim.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 15px 10px 0 0;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wplancer.com%2Feasy-php-i-introduction%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wplancer.com%2Feasy-php-i-introduction%2F&amp;source=banago&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<h3>Introduction</h3>
<p><img class="size-medium wp-image-925 alignright" title="php-tux" src="http://www.wplancer.com/wp-content/php-tux-249x249.jpg" alt="php-tux" width="249" height="249" /></p>
<p>I&#8217;ve been involved with PHP since I got into the web design and development world. This is because since in my beginnings I chose to use WordPress as a CMS to build websites with and since that day I have been needing PHP to build WordPress themes (and plug-ins lately). I have learned a lot of PHP tips and tricks, but I have not yet been able to study it regularly and eventually an advanced programmer as I aim. Hence I would love to be fluent in PHP and I know that it would open a whole new business world in front of me. So, in order to push myself into the academical learning process, I will be writing down my learning experience into tutorials. In this way I hope to kill two birds with one stone: learn deeper PHP for myself and let others learn faster and hopefully better through these tutorials too. So, let&#8217;s get the hands dirty.</p>
<h3>What the Heck is PHP</h3>
<p>To get started we need to know what we are talking about. There are two different opinions as where PHP derives from. The first one tells us it stands for “Personal Home Page Tools” and the second one stands for “Hypertext Preprocessor”. No matter where it derives as a acronym, PHP is server-side programming language. It is the one responsible for taking our requests to the server and bringing to us what the server gives it. PHP can be embedded within your HTML and vice versa which is something that makes it a great language. PHP file extension end in “.php”. PHP supports a ton of databases such as: MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc, but it seems to have chosen the first one, MySQL, to marry with. The last but not the least, PHP is an open source software and is free to download and use.</p>
<h3>Why Should I Use PHP</h3>
<p>PHP is free, open source and has a great community after it. PHP is now mature and can fulfill your every wish. Furthermore, it&#8217;s aimed for the web and it gets to work done. PHP is compatible with almost all servers used today (Apache, IIS, etc.) and almost every hosting company offers PHP enabled hosting service. PHP is also easy and fun to learn as these tutorials will prove it. Moreover, PHP is so popular that if you&#8217;re looking for a career in the web design/web development industry then you just have to know it. Final word: it has proven itself over the years to be one of the best options for dynamic web applications.</p>
<h3>Am I Ready to Learn PHP</h3>
<p>Off course you are! However, you need to have a basic understanding of (X)HTML. That is all you need. However, knowing some JavaScript and CSS would make the situation a lot more fun.</p>
<h3>How to Start with PHP</h3>
<p>You need a developing environment to write and run PHP code. Basically you need to have Apache Server, MySQL and PHP installed on your computer. You can install them separately, but it is not a wise go. The best option to start with whether you are a Linux, Mac, Windows or even Solaris user is XAMPP. XAMPP is a compilation of Apache server, MySQL and PHP and a bunch of other applications like PHPMyAdmin, all-in-one. As I mentioned, it is cross-platform and really easy to use. I use it myself and I love it. You can download at <a title="Download XAMPP" href="http://www.apachefriends.org/en/xampp.html">ApacheFriends.org</a>. However, there are other options that you can consider like : WAMP specifically for Windows found at <a title="Download WAMP" href="http://www.wampserver.com">WampServer.com</a>. MAMP specifically for Mac found at <a title="Download MAMP" href="http://www.mamp.info">Mamp.info</a>. Pick and choose!</p>
<h3>Basic PHP Syntax</h3>
<p>A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Below, we have an example of a simple PHP script which sends the text &#8220;PHP is cool, right?&#8221; to the browser:</p>
<pre class="php">
<span class="htmlOtherTag">&lt;html&gt;</span>
<span class="htmlOtherTag">&lt;body&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span> <span class="phpString">"PHP is cool, right<span class="phpOperator">?</span>"</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/body&gt;</span>
<span class="htmlOtherTag">&lt;/html&gt;</span>
</pre>
<p>Here is the result we seen in the browser form the above PHP code.</p>
<p><img class="alignnone size-full wp-image-917" title="php-is-cool" src="http://www.wplancer.com/wp-content/php-is-cool.png" alt="" width="600" height="285" /></p>
<p>Each code line in PHP must end with a semicolon (;). The semicolon is a separator and is used to distinguish one set of instructions from another. Also, as you can see the text is wrapped with double quotes. We can use single quotes in its place too. There is a slight difference between double and single quotes that we are going to discuss in the next tutorial. Also, there are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text &#8220;My PHP Script&#8221;. Note: The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.</p>
<h3>Comments in PHP</h3>
<p>Commenting your code is a programming virtue. It is a practice of best programmers and one of principles of programming engineering. Commenting your code helps you to understand what you have been writing in the past as you might forget programming tricks and functions once in a while, also, it help others to expand and improve your code easily. So, always comment your code.</p>
<p>In PHP, we use // and # to make a single-line comment or /* and */ to make a multi-line comment block. Have a look at the example below.</p>
<pre class="php">
<span class="htmlOtherTag">&lt;html&gt;</span>
<span class="htmlOtherTag">&lt;body&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//This is a single line comment
</span>#This is a singe line comment too
<span class="phpComment">/*
This is a comment block<span class="phpOperator">.</span> Works the
same way<span class="phpKeyword"> as </span>commenting CSS code.
*/</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/body&gt;</span>
<span class="htmlOtherTag">&lt;/html&gt;</span>
</pre>
<p>This is how PHP looks like, but this is only the first step. To learn more fun things about PHP, read the next tutorial. <em><strong>Note</strong>: If the tutorial name does not have an active link, it means it is not posted yet, so stay tuned.</em></p>
<h3>What is next:</h3>
<ul>
<li>PHP Introduction</li>
<li><a title="PHP Variables" href="http://www.wplancer.com/easy-php-ii-variables/">PHP Variables</a></li>
<li>PHP Operators</li>
<li>PHP Arrays</li>
<li>PHP Loops
<ul>
<li>PHP If … Else</li>
<li>PHP While</li>
<li>PHP Foreach</li>
<li>PHP For</li>
<li>PHP Case</li>
<li>PHP Switch</li>
</ul>
</li>
<li>PHP Functions</li>
<li>PHP Forms
<ul>
<li>$_GET</li>
<li>$_POST</li>
<li>$_REQUEST</li>
</ul>
</li>
<li>PHP Cookies</li>
<li>PHP Sessions</li>
</ul>
<h3>Resources:</h3>
<ol>
<li>PHP Introduction: <a href="http://www.w3schools.com/PHP/php_intro.asp">http://www.w3schools.com/PHP/php_intro.asp</a></li>
<li>PHP Syntax: <a href="http://www.w3schools.com/PHP/php_syntax.asp">http://www.w3schools.com/PHP/php_syntax.asp</a></li>
<li>Learn PHP from Scratch: A Training Regimen: <a href="http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/">http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.wplancer.com/easy-php-i-introduction/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to Display Recent Comments Without Using a Plugin or Widget</title>
		<link>http://www.wplancer.com/how-to-display-recent-comments-without-using-a-plugin-or-widget/</link>
		<comments>http://www.wplancer.com/how-to-display-recent-comments-without-using-a-plugin-or-widget/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 12:32:04 +0000</pubDate>
		<dc:creator>BANAGO</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.wplancer.com/?p=603</guid>
		<description><![CDATA[Yes, that&#8217;s right, you can have comments displayed in your blog or site running on WordPress without using neither the classic pre-built Recent Comments Widget nor any of the Recent Comments Plugins that are available out there for everybody to use. To do so you need to have two pieces of PHP code with little [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 15px 10px 0 0;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wplancer.com%2Fhow-to-display-recent-comments-without-using-a-plugin-or-widget%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wplancer.com%2Fhow-to-display-recent-comments-without-using-a-plugin-or-widget%2F&amp;source=banago&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><div id="attachment_623" class="wp-caption alignright" style="width: 260px"><a href="http://www.banago.info/"><img src="http://www.wplancer.com/wp-content/comments-without-a-plugin-or-widget-250x250.png" alt="Comment Without a Plugin or Widget Live" title="comments-without-a-plugin-or-widget" width="250" height="250" class="size-medium wp-image-623" /></a><p class="wp-caption-text">Comment Without a Plugin or Widget Live</p></div>Yes, that&#8217;s right, you can have comments displayed in your blog or site running on WordPress without using neither the classic pre-built <em>Recent Comments Widget</em> nor any of the <em>Recent Comments Plugins</em> that are available out there for <a href="http://wordpress.org/extend/plugins/" title="WordPress Plugins">everybody to use</a>. To do so you need to have two pieces of PHP code with little (X)HTML code around it. We will not deal with CSS styling in this post, sorry. The first part is to be put on your<em> <strong>functions.php</strong></em> theme file and the second part wherever you feel like doing so in theme. So, let&#8217;s get our hands dirty.</p>
<p>Here is the code that you need to put in your <em>functions.php. </em></p>
<pre class="php">
<span class="htmlOtherTag">&lt; ?php // Get Recet Comments Function
function dp_recent_comments($no_comments = 10, $comment_len = 35) {
    global $wpdb;
	$request = &quot;SELECT * FROM $wpdb-&gt;</span>comments&quot;;
	$request .= &quot; JOIN $wpdb-&gt;posts ON ID = comment_post_ID&quot;;
	$request .= &quot; WHERE comment_approved = &#039;1&#039; AND post_status = &#039;publish&#039; AND post_password =<span class="htmlAttributeValue">&#039;&#039;</span>&quot;;
	$request .= &quot; ORDER BY comment_date DESC LIMIT $no_comments&quot;;
	$comments = $wpdb-&gt;get_results($request);
	if ($comments) {
		foreach ($comments as $comment) {
			ob_start();
			?&gt;
				<span class="htmlOtherTag">&lt;li&gt;</span>
					<span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span><span class="htmlText"> get_permalink</span><span class="phpOperator">(</span> $comment<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">comment_post_ID </span><span class="phpOperator">)</span> <span class="phpOperator">.</span> <span class="phpString">'#comment-'</span> <span class="phpOperator">.</span> $comment<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">comment_ID</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>&quot;</span>&gt;</span><span class="htmlOtherTag">&lt; ?php echo dp_get_author($comment); ?&gt;</span>:<span class="htmlAnchorTag">&lt;/a&gt;</span>
					<span class="htmlOtherTag">&lt; ?php echo strip_tags(substr(apply_filters(&#039;get_comment_text&#039;, $comment-&gt;</span>comment_content), 0, $comment_len)); ?&gt;
				<span class="htmlOtherTag">&lt;/li&gt;</span>
			<span class="htmlOtherTag">&lt; ?php
			ob_end_flush();
		}
	} else {
		echo &#039;&lt;li&gt;</span>&#039;.__(&#039;No comments&#039;, &#039;banago&#039;).&#039;&#039;;
	}
}
function dp_get_author($comment) {
	$author = &quot;&quot;;
	if ( empty($comment-&gt;comment_author) )
		$author = __(&#039;Anonymous&#039;, &#039;banago&#039;);
	else
		$author = $comment-&gt;comment_author;
	return $author;
}?&gt;
</pre>
<p>You need to stop at two moments in the code:</p>
<p>The first one is the comment length. You can change the the length of the comment excerpt that you want to display on your blog by setting the number of the characters here:</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> dp_recent_comments<span class="phpOperator">(</span>$no_comments <span class="phpOperator">=</span> 10, $comment_len <span class="phpOperator">=</span> 35<span class="phpOperator">)</span>
</pre>
<p>The second is the comment wrapping.</p>
<pre class="php">
<span class="phpFunction">echo</span> <span class="phpString">'<span class="phpOperator">&lt;</span>li<span class="phpOperator">&gt;</span>'</span>.__<span class="phpOperator">(</span><span class="phpString">'No comments'</span>, <span class="phpString">'banago'</span><span class="phpOperator">)</span>.<span class="phpString">'<span class="phpOperator">&lt;</span>/li<span class="phpOperator">&gt;</span>'</span><span class="phpText">;</span>
</pre>
<p>It is normally wrapped in <em>&lt;li&gt;comment&lt;/li&gt;</em> because you are supposed to wrap the comments query in by a ordered or unordered list, as we will see below. However, you can change the wrapping tags to whatever you like.</p>
<p>The final step of this process is querying the comments to display on your desired part of the blog or site. All you have to do now is to put the code below where you like on your theme.</p>
<p>Here is the code to query the comments to display on you theme. Please note that the number in the brackets sets the number of the comment to be displayed &#8211; you can change it to fit your needs. </p>
<pre class="php">
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;custom widget&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;h3&gt;</span>Recent Comments<span class="htmlOtherTag">&lt;/h3&gt;</span>
<span class="htmlOtherTag">&lt;ul&gt;</span>
<span class="htmlOtherTag">&lt; ?php dp_recent_comments(6); ?&gt;</span>
<span class="htmlOtherTag">&lt;/ul&gt;</span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>If you found this short tutorial helpful or your need any sort of help, just write a short comment below. Thanks and good luck!</p>
<h3>UPDATE: This has been a quite active post and I can see that a lot of people need this functionality. If you want this on your blog/site, but you do not know how to do that, please <a href="http://www.wplancer.com/contact/">drop me a line</a>.</h3>
]]></content:encoded>
			<wfw:commentRss>http://www.wplancer.com/how-to-display-recent-comments-without-using-a-plugin-or-widget/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>How to remove nofollow attribute from your WordPress blog</title>
		<link>http://www.wplancer.com/how-to-remove-nofollow-attribute-from-your-wordpress-blog/</link>
		<comments>http://www.wplancer.com/how-to-remove-nofollow-attribute-from-your-wordpress-blog/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 19:48:58 +0000</pubDate>
		<dc:creator>BANAGO</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.wplancer.com/?p=248</guid>
		<description><![CDATA[As you may already know, WordPress the rel=”nofollow” attribute in comments. That makes any comment with a link on it have no significance for Google when they ranks websites. Getting rid of the rel=&#8221;nofollow&#8221; attribute is one of the tactics that many WordPress bloggers follow to get more people comment on their blogs. And in [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 15px 10px 0 0;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wplancer.com%2Fhow-to-remove-nofollow-attribute-from-your-wordpress-blog%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wplancer.com%2Fhow-to-remove-nofollow-attribute-from-your-wordpress-blog%2F&amp;source=banago&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>As you may already know, WordPress the <em>rel=”nofollow” </em>attribute in comments. That makes any comment with a link on it have no significance for Google when they ranks websites. Getting rid of the rel=&#8221;nofollow&#8221; attribute is one of the tactics that many WordPress bloggers follow to get more people comment on their blogs. And in my view, this is quite fair &#8211; comments add content to a certain blog, the blog pays them back with a link that will be counted by Google, will rise their pagerank and make their way up in Google searches. So, let&#8217;s begin.</p>
<p>There are two ways through which you can turn off <em>rel=”nofollow”</em> attribute in your blog:</p>
<h3>1. Changing WordPress Core</h3>
<p>Editing WordPress core might not be a good idea for bloggers who are not very familiar with coding. For others, like me, who can do any code editing, online through FTP or offline, this is something that they do everyday. That would save the time of downloading, installing and making work another plugin. However, keep in mind that you need to redo this action every time you do an upgrade.</p>
<p>There is only one file you need to edit and all you have to do is remove the word <em>nofollow</em>. This word is located at <em>wp-includes/comment-template.php</em> on line 148. It looks like this:</p>
<pre class="php">
$return <span class="phpOperator">=</span> <span class="phpString">"<span class="phpOperator">&lt;</span>a rel="</span>external nofollow<span class="phpString">" href="</span>$url<span class="phpString">"<span class="phpOperator">&gt;</span>$author<span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
</pre>
<p>All you have to do is remove the word <em>nofollow </em>only and save the file.  This is it!</p>
<p><a href="http://www.wplancer.com/wp-content/wordpress-remove-no-follow.png"><img class="alignnone size-full wp-image-251" title="wordpress-remove-no-follow" src="http://www.wplancer.com/wp-content/wordpress-remove-no-follow.png" alt="wordpress-remove-no-follow" width="600" height="286" /></a></p>
<h3>2. Employing a Plugin</h3>
<p>If you do not feel comfortable with editing the WordPress core, you can employ a plugin to do that for you. Keep in mind that you will have the plugin too, when new versions are released. Below you will find a list of such plugins. Chose the one that is good for you and install it.</p>
<ol>
<li><a title="DoFollow" href="http://kimmo.suominen.com/sw/dofollow/" target="_blank">DoFollow 4.0</a></li>
<li><a title="NoFollow Free" href="http://www.michelem.org/wordpress-plugin-nofollow-free/" target="_blank">NoFollow Free</a></li>
<li><a title="Lucias Linky Love" href="http://money.bigbucksblogger.com/lucias-linky-love-a-dofollow-plugin-to-foil-human-comment-spammers/" target="_blank">Lucia&#8217;s Linky Love</a></li>
<li><a title="Sem Nofollow" href="http://www.semiologic.com/software/wp-tweaks/dofollow/" target="_blank">Sem NoFollow</a></li>
<li><a title="Link Love" href="http://www.allpassionmarketing.com/blog/2007/02/share-the-link-love-again.html" target="_blank">Link Love</a></li>
<li><a title="Remove Nofollow" href="http://www.seopedia.org/personal/remove-nofollow-from-wordpress-comments/" target="_blank">Remove Nofollow</a></li>
</ol>
<p>Time for publicity: By removing the <em>nofollow attribute</em> you are giving something away for free to your visitors, tell this to your visitors. You will motivate more people to comment for sure. Good luck!</p>
<p>PS: Don&#8217;t forget that WPlancer is a DoFollow blog and I love to hear what you think. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wplancer.com/how-to-remove-nofollow-attribute-from-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>WordPress Bug: Tags do not appear under WP_Query</title>
		<link>http://www.wplancer.com/wordpess-bug-tags-do-not-appear-under-wp_query/</link>
		<comments>http://www.wplancer.com/wordpess-bug-tags-do-not-appear-under-wp_query/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 00:23:05 +0000</pubDate>
		<dc:creator>BANAGO</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.wplancer.com/?p=75</guid>
		<description><![CDATA[WordPress has been perfect and bug-free for me. However, I discovered one lately. Firstly I came across this bug when I was developing an Gawker-style WordPress theme for a client of mine. I used custom WP_Query loops several times there and I was asked to display tags inside them too, the way Gawker does. This [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 15px 10px 0 0;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wplancer.com%2Fwordpess-bug-tags-do-not-appear-under-wp_query%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wplancer.com%2Fwordpess-bug-tags-do-not-appear-under-wp_query%2F&amp;source=banago&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>WordPress has been perfect and bug-free for me. However, I discovered one lately. Firstly I came across this bug when I was developing an <a title="Gawker Style WordPerss theme" href="http://lesdelicieux.com/" target="_blank">Gawker-style</a> WordPress theme for a client of mine. I used custom <a title="WP_Query" href="http://codex.wordpress.org/Function_Reference/WP_Query" target="_blank"><em>WP_Query</em></a> loops several times there and I was asked to display tags inside them too, the way Gawker does. This did not happen, of course, that is why I am writing this post. By that time I thought it was my fault that tags did not appear.</p>
<p>A couple of weeks ago, I coded a new theme for my blog. I used several custom loops there too, powered by the famous <a title="WordPress Loop" href="http://codex.wordpress.org/The_Loop" target="_blank">WP_Query</a>. When I tried again to show the tags inside them, they did not show up. That made assured me that it was a bug. To have more context about this, please have a look at the following WordPress loop:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> $my_query <span class="phpOperator">=</span><span class="phpKeyword"> new </span><span class="htmlText">WP_Query</span><span class="phpOperator">(</span><span class="phpString">'category_name=featured&#038;amp<span class="phpText">;</span>showposts=<span class="phpNumber">1</span>'</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
while </span><span class="phpOperator">(</span>$my_query<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">:</span> $my_query<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">the_post</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
$do_not_duplicate<span class="phpOperator">[</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">ID</span><span class="phpOperator">]</span> <span class="phpOperator">=</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">ID</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;featured_post&quot;</span> id=<span class="htmlAttributeValue">&quot;post-<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_ID</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span></span>&quot;</span>&gt;
<span class="htmlImageTag">&lt;img src=<span class="htmlAttributeValue">&quot;<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span><span class="htmlText"> get_post_meta</span><span class="phpOperator">(</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span></span>ID, <span class="phpString">'Featured_Image'</span>,<span class="phpKeyword"> true<span class="phpOperator">)</span></span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>&quot;</span> alt=<span class="htmlAttributeValue">&quot;&quot;</span> id=<span class="htmlAttributeValue">&quot;featured_img&quot;</span> /&gt;
<span class="htmlOtherTag">&lt;h3 class=<span class="htmlAttributeValue">&quot;title&quot;</span>&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_permalink</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>&quot;</span> rel=<span class="htmlAttributeValue">&quot;bookmark&quot;</span> title=<span class="htmlAttributeValue">&quot;Permanent Link to <span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_title_attribute</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>&quot;</span>&gt;</span><span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_title</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span><span class="htmlAnchorTag">&lt;/a&gt;</span>  <span class="htmlOtherTag">&lt;/h3&gt;</span>
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;meta&quot;</span>&gt;</span>By <span class="htmlOtherTag">&lt;strong&gt;</span><span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_author</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span><span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span><span class="htmlOtherTag">&lt;/strong&gt;</span> &raquo;
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> comments_popup_link</span><span class="phpOperator">(</span><span class="phpString">'<span class="phpNumber">0</span> comments'</span>, <span class="phpString">'<span class="phpNumber">1</span>  comment'</span>, <span class="phpString">'% comments'</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_tags</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_excerpt</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="phpKeyword"> endwhile<span class="phpText">;</span></span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>As you can see, the tags code is included in the loop, but nothing appears. This does not work only under the WP_Query powered loops, whereas in a normal loop, it works. I would appreciate very much that everybody contributes to make this bug known to the WordPress team as soon as possible so that they can have it fixed. Thanks very much!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wplancer.com/wordpess-bug-tags-do-not-appear-under-wp_query/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
