<?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>Andy Weigel &#187; Wordpress How-To&#8217;s</title>
	<atom:link href="http://andyweigel.com/blog/category/wordpress-how-tos/feed" rel="self" type="application/rss+xml" />
	<link>http://andyweigel.com/blog</link>
	<description>Web Development Tutorials</description>
	<lastBuildDate>Thu, 12 Aug 2010 18:53:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to Exclude a Category from the WordPress Loop</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/how-to-exclude-a-category-from-the-wordpress-loop/53</link>
		<comments>http://andyweigel.com/blog/wordpress-how-tos/how-to-exclude-a-category-from-the-wordpress-loop/53#comments</comments>
		<pubDate>Thu, 23 Jul 2009 20:09:54 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Wordpress How-To's]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=53</guid>
		<description><![CDATA[Here&#8217;s the question that was asked: &#8220;Basically I want to take all of the posts in the &#8220;Freelance&#8221; category and remove them from the main content so that I can link to them from a page instead of including them in the Loop. &#8221; Here is the code to exclude an entire category from appearing [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the question that was asked:</p>
<p>&#8220;Basically I want to take all of the posts in the &#8220;Freelance&#8221; category and remove them from the main content so that I can link to them from a page instead of including them in the Loop. &#8221;</p>
<p><strong>Here is the code to exclude an entire category from appearing within the WordPress loop:</strong></p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> query_posts</span><span class="phpOperator">(</span><span class="phpString">'cat<span class="phpOperator">=</span>-<span class="phpNumber">3</span>'</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="phpKeyword"> if </span><span class="phpOperator">(</span><span class="htmlText"> have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="phpKeyword"> while </span><span class="phpOperator">(</span><span class="htmlText"> have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="htmlText"> the_post</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="htmlComment"><span class="htmlOtherTag">&lt;!-- Display the Title as a link to the Post&#039;s permalink. --&gt;</span></span>
<span class="htmlOtherTag">&lt;h2&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;/h2&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> the_content</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="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="phpKeyword"> endwhile<span class="phpText">;</span></span><span class="phpKeyword"> else<span class="phpOperator">:</span></span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;p&gt;</span>Sorry, no posts matched your criteria.<span class="htmlOtherTag">&lt;/p&gt;</span>
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="phpKeyword"> endif<span class="phpText">;</span></span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Basically, what you&#8217;re doing with the above code is telling the loop that if it&#8217;s in category 3, just remove it from the query that the loop is using.</p>
<p>Hopefully you&#8217;ve found this quick tutorial valuable. Contact me if you have any questions or would do it a different way. There&#8217;s 1,001 ways to do everything &#8211; that&#8217;s why I love coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/wordpress-how-tos/how-to-exclude-a-category-from-the-wordpress-loop/53/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Great Grand Parent ID&#8217;s in WordPress</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44</link>
		<comments>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44#comments</comments>
		<pubDate>Fri, 10 Jul 2009 19:21:06 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Wordpress How-To's]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=44</guid>
		<description><![CDATA[Have you ever needed to find all the ancestor ID&#8217;s of a page in WordPress? If so, you&#8217;ve come to the right place. Here&#8217;s some quick code to give you up to the great grand parent ID. $current = $post-&#62;ID; $parent = $post-&#62;post_parent; $get_grandparent = get_post($parent); $grandparent = $get_grandparent-&#62;post_parent; $get_greatgrandparent = get_post($grandparent); $greatgrandparent = $get_greatgrandparent-&#62;post_parent; [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever needed to find all the ancestor ID&#8217;s of a page in WordPress? If so, you&#8217;ve come to the right place. Here&#8217;s some quick code to give you up to the great grand parent ID.</p>
<pre class="php"> $current <span class="phpOperator">=</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>ID<span class="phpText">;</span>
$parent <span class="phpOperator">=</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>post_parent;
$get_grandparent <span class="phpOperator">=</span> get_post<span class="phpOperator">(</span>$parent<span class="phpOperator">)</span><span class="phpText">;</span>
$grandparent <span class="phpOperator">=</span> $get_grandparent<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>post_parent;
$get_greatgrandparent <span class="phpOperator">=</span> get_post<span class="phpOperator">(</span>$grandparent<span class="phpOperator">)</span><span class="phpText">;</span>
$greatgrandparent <span class="phpOperator">=</span> $get_greatgrandparent<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>post_parent; 
<span class="phpFunction">echo</span> <span class="phpString">"parent <span class="phpOperator">=</span> $parent; grandparent <span class="phpOperator">=</span> $grandparent; greatgrandparent <span class="phpOperator">=</span> $greatgrandparent"</span><span class="phpText">;</span>
</pre>
<p> If you wanted to, you could continue this pattern to N number of ancestors&#8230;</p>
<p>Hopefully you&#8217;ve found this quick tutorial valuable. Contact me if you have any questions or would do it a different way. There&#8217;s 1,001 ways to do everything &#8211; that&#8217;s why I love coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Style WordPress Titles Based on Number of Letters</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-titles-based-on-number-of-letters/56</link>
		<comments>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-titles-based-on-number-of-letters/56#comments</comments>
		<pubDate>Wed, 08 Jul 2009 20:11:50 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Wordpress How-To's]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=56</guid>
		<description><![CDATA[A common problem that I&#8217;ve encountered &#8211; how to control dynamic text based on how long it is. In this case I had titles ranging from 10 characters to 25 characters &#8211; this includes spaces. The goal is to make them centered regardless of how many letters and spaces are in the title. Here is [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem that I&#8217;ve encountered &#8211; <strong>how to control dynamic text based on how long it is</strong>. In this case I had titles ranging from 10 characters to 25 characters &#8211; this includes spaces. The goal is to make them centered regardless of how many letters and spaces are in the title.</p>
<p><strong>Here is an example of one of the shorter titles I was given:</strong><br />
	    <img src="http://andyweigel.com/images/single-line-title.jpg" width="455" height="111" alt="single-line-title" /></p>
<p><strong>Here is an example of one of the longer titles I was given:</strong><br />
	    <img src="http://andyweigel.com/images/double-line-title.jpg" width="460" height="114" />		</p>
<p>A series of quick if/else statements and use of the strlen function in PHP allows me to assign different classes depending on the length of the dynamic title. I figured out, based on the CSS on the H1 class, that 14 was my magic number.</p>
<p><strong>Here&#8217;s the quick snippet of code I used:</strong></p>
<pre class="php">
$title <span class="phpOperator">=</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>post_title<span class="phpText">;</span>
$char_title <span class="phpOperator">=</span> <span class="phpFunction">strlen</span><span class="phpOperator">(</span>$title<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span>$char_title <span class="phpOperator">&gt;</span> 14<span class="phpOperator">)</span> <span class="phpOperator">{</span>$header_style <span class="phpOperator">=</span> <span class="phpString">"double"</span><span class="phpText">;</span><span class="phpOperator">}</span>
<span class="phpKeyword">
else </span><span class="phpOperator">{</span>$header_style <span class="phpOperator">=</span> <span class="phpString">"single"</span><span class="phpText">;</span><span class="phpOperator">}</span></pre>
<p>I grab the post title using common WordPress calls and make it into the $title variable. The I use the strlen function to determine the number of characters (including spaces) in the title. If it&#8217;s greater than 14, it assigns the $header_style variable the class &#8220;double&#8221; or else it assigns it the &#8220;single&#8221; class.</p>
<p><strong>Here is how I used it within the WordPress loop:</strong></p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="phpKeyword"> if </span><span class="phpOperator">(</span><span class="htmlText">have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="phpKeyword"> while </span><span class="phpOperator">(</span><span class="htmlText">have_posts</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="htmlText"> the_post</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 class=<span class="htmlAttributeValue">&quot;<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span> $header_style <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span></span>&quot;</span>&gt;<span class="htmlOtherTag">&lt;h2&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="htmlOtherTag">&lt;/h2&gt;</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="phpKeyword"> endif<span class="phpText">;</span></span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Hopefully you&#8217;ve found this quick tutorial valuable. <a href="contact.php">Contact me</a> if you have any questions or would do it a different way. There&#8217;s 1,001 ways to do everything &#8211; that&#8217;s why I love coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-titles-based-on-number-of-letters/56/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
