<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bavotasan.com &#187; post columns</title>
	<atom:link href="http://bavotasan.com/tag/post-columns/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The New Columns Function in Arturo</title>
		<link>http://bavotasan.com/2011/the-new-columns-function-in-arturo/</link>
		<comments>http://bavotasan.com/2011/the-new-columns-function-in-arturo/#comments</comments>
		<pubDate>Wed, 11 May 2011 13:25:26 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[arturo]]></category>
		<category><![CDATA[Columns]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[post columns]]></category>
		<category><![CDATA[theme framework]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress framework]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3383</guid>
		<description><![CDATA[I have just release the latest update to my WordPress theme framework Arturo. I have added many new features but one of the most interesting one is the new arturo_columns() function. This function allows you to create multi-grid layouts for your posts, similar to Magazine Basic and Magazine Premium. Here is a snapshot of the [...]]]></description>
			<content:encoded><![CDATA[<p>I have just release the latest update to my WordPress theme framework <a href="http://themes.bavotasan.com/our-themes/premium-themes/arturo/">Arturo</a>. I have added many new features but one of the most interesting one is the new <code>arturo_columns()</code> function. This function allows you to create multi-grid layouts for your posts, similar to Magazine Basic and Magazine Premium.</p>
<p>Here is a snapshot of the <a href="http://themes.bavotasan.com/our-themes/premium-themes/arturo/">Arturo</a> demo:</p>
<p><img class="aligncenter size-full wp-image-3384" title="arturo-demo" src="http://bavotasan.com/wp-content/uploads/2011/05/arturo-demo.jpg" alt="" width="550" height="500" /></p>
<p>You can see it live at: <a href="http://demos.bavotasan.com/arturo/">http://demos.bavotasan.com/arturo/</a></p>
<p>By default, the posts appear in a single column underneath the slideshow. Let&#8217;s try to change that using the new <code>arturo_columns()</code> function. First let&#8217;s take a look at the function and its arguments:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'full'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// 'full' or number</span>
	<span style="color: #0000ff;">'columns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'posts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'text'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'excerpt'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// 'excerpt' or 'content'</span>
	<span style="color: #0000ff;">'readmore'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
	<span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'all'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// 'all' or category ID</span>
	<span style="color: #0000ff;">'dates'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
	<span style="color: #0000ff;">'authors'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
	<span style="color: #0000ff;">'comments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
	<span style="color: #0000ff;">'images'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
	<span style="color: #0000ff;">'img_w'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'img_h'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'img_align'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignright'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// 'alignleft', 'alignright', 'aligncenter' or 'alignnone'</span>
	<span style="color: #0000ff;">'margin_right'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// text header that appears above columns</span>
	<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// text ID for div container</span>
	<span style="color: #0000ff;">'padding'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'gap'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// number</span>
	<span style="color: #0000ff;">'sticky'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
	<span style="color: #0000ff;">'masonry'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #666666; font-style: italic;">// boolean (1 = on, 0 = off)</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>There are quite a few arguments but you really don&#8217;t need to set all of them since the defaults are sufficient for simple changes. The easiest mod would be to create two columns instead of one. Open up your Custom Actions editor and add this block of code:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'arturo_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> new_loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'columns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'posts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>First we need to remove the current action <code>arturo_loop</code> and then add our new action <code>new_loop</code> to the <code>arturo_index_middle</code> hook. Now <a href="http://themes.bavotasan.com/our-themes/premium-themes/arturo/">Arturo</a> will look like this:</p>
<p><img src="http://bavotasan.com/wp-content/uploads/2011/05/arturo_2col.jpg" alt="" title="arturo_2col" width="550" height="600" class="aligncenter size-full wp-image-3385" /></p>
<p>We could even take it a step further and include a single post displaying the full content above the two columns by adding this block of code:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'arturo_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> new_loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$paged</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$paged</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'columns=1&amp;posts=1&amp;img_align=alignleft&amp;text=content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'columns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'posts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>That little conditional tag near the beginning of the <code>new_loop()</code> function will make sure that the single column first post only appears on the front page and not any subsequent page. Take at look at the site now:</p>
<p><img src="http://bavotasan.com/wp-content/uploads/2011/05/arturo_1col-2col.jpg" alt="" title="arturo_1col-2col" width="550" height="600" class="aligncenter size-full wp-image-3387" /></p>
<p>We could even easily remove that slideshow to move our posts up with a simple additional line of code:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_top'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'arturo_index_top_slideshow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'arturo_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> new_loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$paged</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$paged</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'columns=1&amp;posts=1&amp;img_align=alignleft&amp;text=content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'columns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'posts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Take a look at it now:</p>
<p><img src="http://bavotasan.com/wp-content/uploads/2011/05/arturo_no-slideshow.jpg" alt="" title="arturo_no-slideshow" width="550" height="600" class="aligncenter size-full wp-image-3390" /></p>
<p>On top of all these modifications that you can create using the new <code>arturo_columns()</code> function, one of the coolest features is the ability to hook into <a href="http://desandro.com/resources/jquery-masonry/">David DeSandro&#8217;s jQuery Masonry</a> plugin. All it takes is this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'arturo_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arturo_index_middle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> new_loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'600'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'columns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'posts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'gap'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'masonry'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'masonry'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   arturo_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wp_footer&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;add_masonry&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> add_masonry<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$twocol</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">600</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// (Width + Gap) / 2 </span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot; src=&quot;https://github.com/desandro/masonry/raw/master/jquery.masonry.min.js&quot;&gt;&lt;/script&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;
(function($) {
	$(window).load(function(){
		$(&quot;#masonry&quot;).masonry({ columnWidth: 315, singleMode: true, itemSelector: &quot;.post&quot; });
	});
})(jQuery);
&lt;/script&gt;
'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>One thing to notice in the above code is that I hard coded some of the arguments. The width, gap and id need to be set in order to make sure the Masonry plugin aligns properly. And you need to make sure to use the following equation to determine the <code>columnWidth</code> var: <em>(width + gap) / 2 = columnWidth</em></p>
<p>With the above code we now get this:</p>
<p><img src="http://bavotasan.com/wp-content/uploads/2011/05/arturo_masonry.jpg" alt="" title="arturo_masonry" width="550" height="800" class="aligncenter size-full wp-image-3393" /></p>
<p>Each posts fits snugly beneath the other. That&#8217;s the power of <a href="http://desandro.com/resources/jquery-masonry/">David DeSandro&#8217;s jQuery Masonry</a> plugin.</p>
<p>By playing around with the samples above you can really start to customize <a href="http://themes.bavotasan.com/our-themes/premium-themes/arturo/">Arturo</a> and see just how powerful it is. Stay tuned for more tutorials on some of the other new features in <a href="http://themes.bavotasan.com/our-themes/premium-themes/arturo/">Arturo v1.0.1</a>. </p>
<div class="imgprov">
<a href="http://themes.bavotasan.com/our-themes/premium-themes/arturo/">Arturo</a> is a theme framework for WordPress created by <a href="http://themes.bavotasan.com/">Themes by bavotasan.com</a>. You can <a href="https://www.e-junkie.com/ecom/gb.php?i=wpt-art-dev&#038;c=single&#038;cl=93121">buy it now</a> for $97.00 USD.
</div>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/the-new-columns-function-in-arturo/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

