<?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>Wed, 27 Oct 2010 00:21:19 +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>WP-E-Commerce Add Tax to Receipt</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/wp-e-commerce-add-tax-to-receipt/184</link>
		<comments>http://andyweigel.com/blog/wordpress-how-tos/wp-e-commerce-add-tax-to-receipt/184#comments</comments>
		<pubDate>Wed, 27 Oct 2010 00:17:31 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Wordpress How-To's]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=184</guid>
		<description><![CDATA[Interested in adding the sales tax to your WP-e-Commerce receipts? It wasn&#8217;t as easy as I had thought. They don&#8217;t record the total tax for each order, so we need to add it up ourselves and add it to both the email receipt and the transaction details screen. The first thing you need to do [...]]]></description>
			<content:encoded><![CDATA[<p>Interested in adding the sales tax to your WP-e-Commerce receipts? It wasn&#8217;t as easy as I had thought. They don&#8217;t record the total tax for each order, so we need to add it up ourselves and add it to both the email receipt and the transaction details screen.<span id="more-184"></span></p>
<p>The first thing you need to do is open the &#8220;transaction-result_functions.php&#8221; file from the wp-e-commerce plugin. Then search for &#8220;$product_list_html.= $row['quantity'].&#8221; -  &#8220;. $product_data['name'].stripslashes($variation_list ).&#8221;  &#8220;. $message_price .&#8221;\n\r&#8221;;&#8221;</p>
<p>Then add this code right after that -</p>
<pre class="php">
$region <span class="phpOperator">=</span> $purchase_log<span class="phpOperator">[</span><span class="phpString">'billing_region'</span><span class="phpOperator">]</span><span class="phpText">;</span>
$region_results <span class="phpOperator">=</span> <span class="phpFunction">mysql_query</span><span class="phpOperator">(</span><span class="phpString">"SELECT * FROM `wp_wpsc_region_tax` WHERE `id` <span class="phpOperator">=</span> $region "</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
while<span class="phpOperator">(</span></span>$r=<span class="phpFunction">mysql_fetch_array</span><span class="phpOperator">(</span>$region_results<span class="phpOperator">)</span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>
$tax_rate <span class="phpOperator">=</span> $r<span class="phpOperator">[</span><span class="phpString">'tax'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
$product_id<span class="phpOperator">[</span><span class="phpOperator">]</span> <span class="phpOperator">=</span> $product_data<span class="phpOperator">[</span><span class="phpString">'id'</span><span class="phpOperator">]</span><span class="phpText">;</span>
$tax_percent <span class="phpOperator">=</span> $tax_rate * <span class="phpOperator">.</span>01<span class="phpText">;</span>
$message_price_clean <span class="phpOperator">=</span> <span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">"$"</span>,<span class="phpString">""</span>,$message_price<span class="phpOperator">)</span><span class="phpText">;</span>
$tax_sub_total <span class="phpOperator">=</span> $message_price_clean * $tax_percent;
$tax_total<span class="phpOperator">[</span><span class="phpOperator">]</span> <span class="phpOperator">=</span> $tax_sub_total;
</pre>
<p>Then find this line &#8211; $product_list_html.= &#8220;Your Purchase No.: &#8220;.$purchase_log['id'].&#8221;\n\n\r&#8221;; and add this</p>
<pre class="php">
$tax_total <span class="phpOperator">=</span> <span class="phpFunction">array_sum</span><span class="phpOperator">(</span>$tax_total<span class="phpOperator">)</span><span class="phpText">;</span>
$tax_total <span class="phpOperator">=</span> <span class="phpFunction">round</span><span class="phpOperator">(</span>$tax_total, <span class="phpNumber">2</span><span class="phpOperator">)</span><span class="phpText">;</span>
$product_list_html<span class="phpOperator">.=</span> <span class="phpString">"Tax<span class="phpOperator">:</span> $"</span> <span class="phpOperator">.</span>$tax_total <span class="phpOperator">.</span><span class="phpString">"\n\r"</span><span class="phpText">;</span>
$product_list<span class="phpOperator">.=</span> <span class="phpString">"Tax<span class="phpOperator">:</span> $"</span> <span class="phpOperator">.</span>$tax_total <span class="phpOperator">.</span><span class="phpString">"\n\r"</span><span class="phpText">;</span>
</pre>
<p>This will add a tax line to both the email receipt and the transaction details screen, after a customer has a made a purchase. If it&#8217;s from a region where sales doesn&#8217;t apply, the tax will be zero.</p>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/wordpress-how-tos/wp-e-commerce-add-tax-to-receipt/184/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Style WordPress Sub Page Menus</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-sub-page-menus/165</link>
		<comments>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-sub-page-menus/165#comments</comments>
		<pubDate>Tue, 05 Oct 2010 16:13:38 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Wordpress How-To's]]></category>

		<guid isPermaLink="false">http://andyweigel.com/blog/?p=165</guid>
		<description><![CDATA[Here&#8217;s a problem I&#8217;ve recently encountered while using the wp_list_pages function for a sub-page menu. The problem was that the &#8220;current_page_item&#8221; class was cascading to all the sub-page elements. Here&#8217;s what it was looking like: The particular function I was using was this: &#60;?php wp_list_pages('title_li=&#038;amp;child_of=5'); ?&#62; And here is what was rendered with that code: [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a problem I&#8217;ve recently encountered while using the wp_list_pages function for a sub-page menu. The problem was that the &#8220;current_page_item&#8221; class was cascading to all the sub-page elements.</p>
<p><span id="more-165"></span></p>
<p>Here&#8217;s what it was looking like:<br />
<img class="size-full wp-image-167" title="sub-page-menu" src="http://andyweigel.com/blog/wp-content/uploads/sub-page-menu.jpg" alt="" width="232" height="164" /></p>
<p>The particular function I was using was this:</p>
<pre class="php"> <span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span><span class="htmlText"> wp_list_pages</span><span class="phpOperator">(</span><span class="phpString">'title_li<span class="phpOperator">=</span>&#038;amp<span class="phpText">;</span>child_of=<span class="phpNumber">5</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>And here is what was rendered with that code:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;span&gt;</span>Products<span class="htmlOtherTag">&lt;/span&gt;</span>
<span class="htmlOtherTag">&lt;ul&gt;</span>
<span class="htmlOtherTag">&lt;ul&gt;</span>
<span class="htmlOtherTag">&lt;li&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span>&gt;</span>Main Page Title 1<span class="htmlAnchorTag">&lt;/a&gt;</span>
<span class="htmlOtherTag">&lt;ul class=<span class="htmlAttributeValue">&#039;children&#039;</span>&gt;</span>
<span class="htmlOtherTag">&lt;li&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span>&gt;</span>Instruction Manuals<span class="htmlAnchorTag">&lt;/a&gt;</span><span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;li&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span>&gt;</span>Literature<span class="htmlAnchorTag">&lt;/a&gt;</span><span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;/ul&gt;</span>
<span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;li&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span>&gt;</span>Main Page Title 2<span class="htmlAnchorTag">&lt;/a&gt;</span>
<span class="htmlOtherTag">&lt;ul class=<span class="htmlAttributeValue">&#039;children&#039;</span>&gt;</span>
<span class="htmlOtherTag">&lt;li&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span>&gt;</span>Instruction Manuals<span class="htmlAnchorTag">&lt;/a&gt;</span><span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;li&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;&quot;</span> title=<span class="htmlAttributeValue">&quot;&quot;</span>&gt;</span>Literature<span class="htmlAnchorTag">&lt;/a&gt;</span><span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;/ul&gt;</span>
<span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;/ul&gt;</span>
<span class="htmlOtherTag">&lt;/ul&gt;</span>
</pre>
<p>All you need to do to control the sub-pages is to add a line to your CSS file. All I had to do was the tell it to use white instead of gray for the link color. Here&#8217;s the CSS I used:</p>
<pre class="css">
li.current_page_item ul li a {
<span class="cssProperty">color</span><span class="cssRest">:</span><span class="cssValue">#FFF</span><span class="cssRest">;</span> <span class="cssImportant">!important</span>
<span class="cssMedia">}</span>
</pre>
<p>Here&#8217;s what it looked like after the CSS fix:</p>
<p><img class="alignnone size-full wp-image-166" title="sub-page-menu-fixed-css" src="http://andyweigel.com/blog/wp-content/uploads/sub-page-menu-fixed-css.jpg" alt="" width="235" height="170" /></p>
]]></content:encoded>
			<wfw:commentRss>http://andyweigel.com/blog/wordpress-how-tos/style-wordpress-sub-page-menus/165/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>3</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>9</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>

