<?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>Monday By Noon &#187; pagination</title>
	<atom:link href="http://mondaybynoon.com/tag/pagination/feed/" rel="self" type="application/rss+xml" />
	<link>http://mondaybynoon.com</link>
	<description>A resource for Web designers and developers to read about and discuss their craft.</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>WordPress Posts Per Page Per Custom Post Type</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20110516%2Fwordpress-posts-per-page-per-custom-post-type%2F&#038;seed_title=WordPress+Posts+Per+Page+Per+Custom+Post+Type</link>
		<comments>http://mondaybynoon.com/20110516/wordpress-posts-per-page-per-custom-post-type/#comments</comments>
		<pubDate>Tue, 17 May 2011 03:33:48 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[Custom Post Type]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=1633</guid>
		<description><![CDATA[With Custom Post Types it&#8217;s quite likely that you&#8217;ll want to use a different number of posts per page in comparison to the Blog pages show at most setting found in Settings > Reading. I&#8217;d strongly suggest avoiding a solution involving the posts_per_page argument of a custom loop and instead use one of the many [...]<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1633&c=385820991' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1633&c=385820991' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>With Custom Post Types it&#8217;s quite likely that you&#8217;ll want to use a different number of posts per page in comparison to the <strong>Blog pages show at most</strong> setting found in Settings > Reading. I&#8217;d strongly suggest avoiding a solution involving the <code>posts_per_page</code> argument of a custom loop and instead use one of the many filters available to us:</p>
<pre class="sh_php"><code>// posts per page based on CPT
function iti_custom_posts_per_page($query)
{
    switch ( $query->query_vars['post_type'] )
    {
        case 'iti_cpt_1':  // Post Type named 'iti_cpt_1'
            $query->query_vars['posts_per_page'] = 3;
            break;

        case 'iti_cpt_2':  // Post Type named 'iti_cpt_2'
            $query->query_vars['posts_per_page'] = 4;
            break;

        case 'iti_cpt_3':  // Post Type named 'iti_cpt_3'
            $query->query_vars['posts_per_page'] = 5;
            break;

        default:
            break;
    }
    return $query;
}

if( !is_admin() )
{
    add_filter( 'pre_get_posts', 'iti_custom_posts_per_page' );
}</code></pre>
<p>This snippet can be added in your theme&#8217;s <code>functions.php</code></p>
<p>Of course, you&#8217;ll want to customize the Custom Post Type names in use, but this will allow the pagination to work properly based on a custom number of entries per page you&#8217;d like to show.</p>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1633&c=1390602332' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1633&c=1390602332' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20110516/wordpress-posts-per-page-per-custom-post-type/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>&#8226; The Last of the Pods Basics: Pagination and Sorting</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20100125%2Fpods-pagination-sorting%2F&#038;seed_title=%26%238226%3B+The+Last+of+the+Pods+Basics%3A+Pagination+and+Sorting</link>
		<comments>http://mondaybynoon.com/20100125/pods-pagination-sorting/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 14:57:57 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Pods]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=736</guid>
		<description><![CDATA[To wrap up the Basics of Pods in January, I'd like to cover the last couple items I feel are almost essential in having the user experience of Pods come full circle for both you and your user. Pods offers both pagination and sorting out of the box, and each can be very helpful when it comes to working with the plugin.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=736&c=1076583693' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=736&c=1076583693' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>The Series on Pods has been quite a success so far. I&#8217;ve had some back and forth with lots of new people who were itching to give Pods a try, and the series has been quite a bit of help to newcomers. I&#8217;m super happy about that, and I&#8217;d like to close out the initial push on the series with what I&#8217;ll call The Last of the Pods Basics. That is to say, I&#8217;d like to go over the last few bits that will really get you up and running with Pods in such a way that you can do even more with both your data as well as your user experience.</p>
<p>As a quick recap, if you haven&#8217;t read the first five articles in The Series, you will probably find this article a bit confusing. That said, please make sure you&#8217;ve read: <a href="/2010/01/04/introduction-to-pods-cms-wordpress/">An Overview of and Introduction to Pods CMS for WordPress</a>, <a href="/2010/01/04/pods-basics-installation-and-setup/">Pods Basics: Installation and Setup</a>, <a href="/2010/01/04/pulling-pods-data/">Pods Basics: Pulling Pods Data to your Theme</a>, <a href="/2010/01/04/pods-ui-intro/">Pods UI: The Latest and Greatest Addition to Pods</a>, and <a href="/2010/01/11/how-to-use-pick-columns-relationships-in-pods/">How to use Pick Columns (Relationships) in Pods</a>. Being up to speed is essential with this article, as it&#8217;s going to build on the system we&#8217;ve put in place using the previously published articles. You won&#8217;t need to recreate the structure set up in the earlier walk throughs, but knowing the existing implementation will help these instructions remain clear.</p>
<h2>Paginated content in Pods</h2>
<p>Pods comes with pagination <em>built right in</em>, it&#8217;s just a matter of getting it to work the way you want. We&#8217;ll begin by flooding the Team Pod we set up previously with a large group of entries. In addition to the Pod setup, I also added <a href="/2010/01/04/pods-ui-intro/">Pods UI</a> to help manage the content.</p>
<p><img src="/images/pods/paging/01-team-listing.jpg" alt="Our new Team listing" /></p>
<p>If we were to check out our Team page now, we&#8217;d see that the listing has been limited to the <strong>default</strong> 15 records:</p>
<p><img src="/images/pods/paging/02-limited-no-warning.jpg" alt="Team listing" /></p>
<p>Also by default, Pods doesn&#8217;t include any sort of warning that content wasn&#8217;t listed. It shouldn&#8217;t do that, because Pods does what you tell it to do. You have a few options here. The first would be to change the way we pull the original data. As it stands, we&#8217;re using:</p>
<pre class="sh_php"><code>&lt;?php
  $team = new Pod(&#x27;team&#x27;);
  $team-&gt;findRecords(&#x27;name ASC&#x27;);
?&gt;</code></pre>
<p>As it turns out, <a href="http://pods.uproot.us/codex/findrecords"><code>findRecords</code></a> has more parameters to work with, one of which is the <code>LIMIT</code> we want to use. You can change the default of 15 by defining the <code>$rows_per_page</code> parameter:</p>
<pre class="sh_php"><code>&lt;?php
  $team = new Pod(&#x27;team&#x27;);
  $team-&gt;findRecords(&#x27;name ASC&#x27;, 20);
?&gt;</code></pre>
<p>If we were to make that change, we&#8217;d see all 16 records we have entered, but would also have the same problem once we breached the new limit of 20. A better solution is to include pagination. We&#8217;ll revert back to the default limit of 15, and include our pagination links below the Team listing. It&#8217;s even easier than it sounds. After you&#8217;ve defined your Pod, you can fire the following anywhere:</p>
<pre class="sh_php"><code>&lt;?php echo $team-&gt;getPagination(); ?&gt;</code></pre>
<p><code>getPagnination()</code> basically takes care of everything, and will include the pagination controls where <code>echo</code>&#8216;d:</p>
<p><img src="/images/pods/paging/03-pagination.jpg" alt="Pagination controls" /></p>
<p>Here&#8217;s the best part, <strong>that&#8217;s all you&#8217;ve got to do</strong>. Clicking the second page appends a couple of <code>$_GET</code> variables, reloads the page, and shows you all of your new data. <em>You&#8217;re done</em>. There are a few more details concerning <a href="http://pods.uproot.us/codex/getpagination"><code>getPagination()</code></a> which will be covered in a subsequent article.</p>
<h2>Sorting Pods entries</h2>
<p>I&#8217;m really excited that the Pods developers are taking so much care with <a href="/2010/01/04/pods-ui-intro/">Pods UI</a>. Beyond the inherent user experience improvements it makes, they&#8217;re adding features that you can&#8217;t even find in WordPress yet. One of my most welcomed additions as of late with Pods UI is the inclusion of drag and drop sorting of Pods entries. Before the functionality was implemented, you had to make a <code>number</code> column in your Pod, and instruct users to use that field to manually order the Pods entries. It was a replication of the limited functionality WordPress offers with Pages. The Pods developers did one better and included such functionality in <a href="http://ui.podscms.org/">Pods UI</a>. As with every other aspect of Pods, it&#8217;s <em>super easy to integrate</em>, we&#8217;ll walk through it quickly.</p>
<p>The first step carries over from the old way of doing things, you&#8217;ll need to add a <code>number</code> column to your Pod. We&#8217;ll continue working with our Team Pod:</p>
<p><img src="/images/pods/sorting/01-displayorder-col.jpg" alt="Adding our number column" /></p>
<p>Once the column is added, we&#8217;re going to need to modify our theme template to <code>ORDER BY</code> that column as opposed to the <code>name</code> column it&#8217;s currently using:</p>
<pre class="sh_php"><code>&lt;?php
  $team = new Pod(&#x27;team&#x27;);
  $team-&gt;findRecords(&#x27;displayorder ASC&#x27;);
  $total_members = $team-&gt;getTotalRows();
?&gt;</code></pre>
<p>Easy enough. You could actually leave things as is, and your user could manually edit each of the <code>displayorder</code> columns for each Pod entry, but Pods UI makes that so much easier. We&#8217;ll need to modify our custom UI plugin and include a few choice flags that will tell Pods UI the details it needs to enable drag and drop sorting. Our <strong>revised</strong> plugin is as follows:</p>
<pre class="sh_php"><code>&lt;?php
/*
Plugin Name: Team Pods UI
Plugin URI: http://example.com/
Description: Customized Pods UI
Version: 0.1
Author: Jonathan Christopher
Author URI: http://jchristopher.me/
*/

function pods_ui_team()
{
  $icon = &#x27;&#x27;;
  add_object_page(&#x27;Team&#x27;, &#x27;Team&#x27;, &#x27;read&#x27;, &#x27;team&#x27;, &#x27;&#x27;, $icon);
  add_submenu_page(&#x27;team&#x27;, &#x27;Team&#x27;, &#x27;Team&#x27;, &#x27;read&#x27;, &#x27;team&#x27;, &#x27;team_page&#x27;);
}

function team_page()
{
  $object = new Pod(&#x27;team&#x27;);
  $add_fields = $edit_fields = array(
        &#x27;name&#x27;,
        &#x27;position&#x27;,
        &#x27;photo&#x27;,
        &#x27;bio&#x27;,
        &#x27;permalink&#x27;,
        &#x27;eom&#x27;);
  $object-&gt;ui = array(
        &#x27;title&#x27;   =&gt; &#x27;Team&#x27;,
        &#x27;reorder&#x27; =&gt; &#x27;displayorder&#x27;,
        &#x27;reorder_columns&#x27; =&gt; array(
             &#x27;name&#x27;      =&gt; &#x27;Name&#x27;,
             &#x27;position&#x27;  =&gt; &#x27;Position&#x27;),
        &#x27;columns&#x27; =&gt; array(
             &#x27;name&#x27;      =&gt; &#x27;Name&#x27;,
             &#x27;position&#x27;  =&gt; &#x27;Position&#x27;,
             &#x27;created&#x27;   =&gt; &#x27;Date Created&#x27;,
             &#x27;modified&#x27;  =&gt; &#x27;Last Modified&#x27;
             ),
        &#x27;add_fields&#x27;  =&gt; $add_fields,
        &#x27;edit_fields&#x27; =&gt; $edit_fields
		);
  pods_ui_manage($object);
}

add_action(&#x27;admin_menu&#x27;,&#x27;pods_ui_team&#x27;);

?&gt;</code></pre>
<p>While it looks very similar to the Pods UI plugin we developed earlier, you&#8217;ll want to note the subtle difference:</p>
<pre class="sh_php"><code>&#x27;reorder&#x27; =&gt; &#x27;displayorder&#x27;,
&#x27;reorder_columns&#x27; =&gt; array(
     &#x27;name&#x27;      =&gt; &#x27;Name&#x27;,
     &#x27;position&#x27;  =&gt; &#x27;Position&#x27;),</code></pre>
<p>These new entries are very important, as they enable the sorting itself, as well as tell Pods which column to use when applying the new sort order. When you break it down it&#8217;s quite simple. You define <code>reorder</code> with the <code>number</code> column you set up and would like to use to control the sort order, and <code>reorder_columns</code> are the table columns that appear on the reorder page in the WordPress admin. After modifying your plugin with the following, a new element will be included on the listing page:</p>
<p><img src="/images/pods/sorting/02-reorder-button.jpg" alt="Our new Reorder button" /></p>
<p>Clicking that button will reload the page and bring the user to a page dedicated to managing the order of the Pods entries:</p>
<p><img src="/images/pods/sorting/03-reorder-page.jpg" alt="Our new Reorder page" /></p>
<p><strong>Beautiful!</strong> Our user can drag and drop to reorder their entries on the fly, click Update Order at the bottom, and everything is taken care of for us.</p>
<h2>Pods never disappoints</h2>
<p>I hope that these last couple basic features give you enough information to really get started working with Pods. The developers have really put a lot of time, effort, love, <strong>and thought</strong> into the implementation and I can&#8217;t thank them enough. If you&#8217;ve found yourself embracing Pods, please take a moment and <a href="http://pods.uproot.us/">donate to the project</a> as I know for a fact they&#8217;re working night and day to make Pods that much better with every release.</p>
<h4>The Pods CMS Series on <abbr title="Monday By Noon">MBN</abbr></h4>
<p>This article is the <strong>sixth</strong> in a series for Monday By Noon dedicated to <a href="http://pods.uproot.us/">Pods CMS</a>.</p>
<ol>
<li><a href="/2010/01/04/introduction-to-pods-cms-wordpress/">An Overview of and Introduction to Pods CMS for WordPress</a></li>
<li><a href="/2010/01/04/pods-basics-installation-and-setup/">Pods Basics: Installation and Setup</a></li>
<li><a href="/2010/01/04/pulling-pods-data/">Pods Basics: Pulling Pods Data to your Theme</a></li>
<li><a href="/2010/01/04/pods-ui-intro/">Pods UI: The Latest and Greatest Addition to Pods</a></li>
<li><a href="/2010/01/11/how-to-use-pick-columns-relationships-in-pods/">How to use Pick Columns (Relationships) in Pods</a></li>
<li><a href="/2010/01/25/pods-pagination-sorting/">The Last of the Pods Basics: Pagination and Sorting</a></li>
</ol>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=736&c=240726132' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=736&c=240726132' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20100125/pods-pagination-sorting/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>&#8226; How to use Pick Columns (Relationships) in Pods</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20100111%2Fhow-to-use-pick-columns-relationships-in-pods%2F&#038;seed_title=%26%238226%3B+How+to+use+Pick+Columns+%28Relationships%29+in+Pods</link>
		<comments>http://mondaybynoon.com/20100111/how-to-use-pick-columns-relationships-in-pods/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 14:57:44 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[Pick columns]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Pods]]></category>
		<category><![CDATA[relationships]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=722</guid>
		<description><![CDATA[Pods Pick columns help you create relationships with WordPress objects or other Pods themselves. It's a great way to bring the content management offered by Pods to the next level.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=722&c=800315050' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=722&c=800315050' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>In this edition of the Pods CMS Series, we&#8217;re going to cover Pick Columns. If you haven&#8217;t read the first articles in the series, I would highly recommend it as this article assumes basic knowledge of the workings of <a href="http://pods.uproot.us/">Pods</a>. Please make sure you&#8217;ve read <a href="/2010/01/04/pods-basics-installation-and-setup/">Pods Basics: Installation and Setup</a>, <a href="/2010/01/04/pulling-pods-data/">Pods Basics: Pulling Pods Data to your Theme</a>, and <a href="/2010/01/04/pods-ui-intro/">Pods UI: The Latest and Greatest Addition to Pods</a> before continuing.</p>
<p>As defined by the Pods developers:</p>
<blockquote cite="http://pods.uproot.us/codex/pick_column">
<p>A relationship column is essentially a select list containing items from the related type. If you create a column in one pod that relates to another pod, &#8220;event&#8221;, then in the edit form you&#8217;ll see a select list with all &#8220;event&#8221; items.</p>
</blockquote>
<p>This is really great for us, because it means that any Pod can effectively make use of another Pod or WordPress resource such as a Page. It opens the doors to quite a few things that were more difficult to achieve using a combination of standalone WordPress plugins.</p>
<h2>When would you want to use relationships?</h2>
<p>When it comes to learning, I always find it better to explore by example. If a technology is applied to a real-life situation (or something very close to that) I find it much easier to fully understand.</p>
<p>Perhaps the most basic use of a Pick column would be to make a link between a Pod entry and a WordPress Page. One example of a situation in which this makes sense is a promotional area. Using Pods, you could set up an area to manage any number of promotions, and have them link directly to a specific WordPress Page.</p>
<h2>How to implement a Pick Column</h2>
<p>We&#8217;ll continue with our Promotions example and create a quick Pod to handle the data. We&#8217;ll set it up like this:</p>
<p><img src="/images/pods/pick/01-pick-setup.jpg" alt="Setting up our Pick column in Pods" /></p>
<p>With our Promotions Pod set up, let&#8217;s add a sample entry to see how the Pick column works:</p>
<p><img src="/images/pods/pick/02-pick-entry.jpg" alt="Data entry for a Pick column" /></p>
<p>It&#8217;s as easy as that! Pods will automatically pull the active list of WordPress pages, so you don&#8217;t have to worry about anything being out of date or inaccurate when it comes to pulling the needed permalink on the front end. Once we&#8217;ve saved the Pod entry, let&#8217;s go ahead and integrate it into our sidebar. For the demo, I&#8217;m just going to work within the default WordPress theme. In <code>sidebar.php</code>:</p>
<pre class="sh_php"><code>&lt;?php
  $promos = new Pod(&#x27;promotion&#x27;);
  $promos-&gt;findRecords(null, 1);
  $total_promos = $promos-&gt;getTotalRows();
?&gt;

&lt;?php if( $total_promos &gt; 0 ) : ?&gt;

  &lt;?php while ( $promos-&gt;fetchRecord() ) : ?&gt;

    &lt;?php
      // set our variables
      $promo_name = $promos-&gt;get_field(&#x27;name&#x27;);
      $promo_copy = $promos-&gt;get_field(&#x27;copy&#x27;);
      $promo_link = $promos-&gt;get_field(&#x27;link&#x27;);

      $promo_link = get_permalink($promo_link[0][&#x27;ID&#x27;]);
    ?&gt;

    &lt;div id=&quot;promo&quot;&gt;
      &lt;h4&gt;&lt;?php echo $promo_name; ?&gt;&lt;/h4&gt;
      &lt;p&gt;&lt;?php echo $promo_copy; ?&gt;&lt;/p&gt;
      &lt;p&gt;&lt;a href=&quot;&lt;?php echo $promo_link; ?&gt;&quot;&gt;Find out more!&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;!-- /promo --&gt;

  &lt;?php endwhile ?&gt;

&lt;?php endif ?&gt;</code></pre>
<p>What we&#8217;re doing here is first pulling our Pod data. If a record is found, we&#8217;re going to process it. Everything is standard practice until it comes to our Pick column. Since we chose the relationship to be a WordPress page, Pods is going to give us an array with which to work. What&#8217;s great is that the array consists of variables we&#8217;re already familiar with by working with WordPress pages. We&#8217;re provided the entire set of data we expect:</p>
<pre><code>Array
(
    [0] => Array
        (
            [ID] => 29
            [post_author] => 1
            [post_date] => 2010-01-01 00:00:00
            [post_date_gmt] => 2010-01-01 00:00:00
            [post_content] =>
            [post_title] => Package 3
            [post_excerpt] =>
            [post_status] => publish
            [comment_status] => open
            [ping_status] => open
            [post_password] =>
            [post_name] => package-3
            [to_ping] =>
            [pinged] =>
            [post_modified] => 2010-01-01 00:00:00
            [post_modified_gmt] => 2010-01-01 00:00:00
            [post_content_filtered] =>
            [post_parent] => 23
            [guid] => http://localhost/wp/?page_id=29
            [menu_order] => 0
            [post_type] => page
            [post_mime_type] =>
            [comment_count] => 0
        )

)</code></pre>
<p>Nice, right? Using that data we can completely integrate the Promotion copy to include a link directly to the page selected in the Pick column. Done, and done:</p>
<p><img src="/images/pods/pick/03-in-sidebar.jpg" alt="Promotion on the front end" /></p>
<p>By all means, that&#8217;s the most basic way to implement the promotion, you can provide additional fields that allow the user to define the promo link text and more.</p>
<h3>Creating relationships with other Pods</h3>
<p>Being able to make a connection with a WordPress Page is <em>awesome</em>, you can also establish these relationships with WordPress Posts, WordPress Users, and even WordPress Categories. Pods also lets you link your Pods to one another. Let&#8217;s continue with our Promotion example.</p>
<p>Perhaps the website you&#8217;re building out has <strong>a lot</strong> of promotions. So many that you&#8217;d like to randomly pull a promotion from a group of promotions at any given time. With Pick columns we can make that happen. The first thing we&#8217;ll do is set up a Promotion Categories Pod. All we need is the most basic structure to work with:</p>
<p><img src="/images/pods/pick/04-categories.jpg" alt="Promotion Categories Pod setup" /></p>
<p>Then we&#8217;ll add a couple categories, one of which can be Winter Specials:</p>
<p><img src="/images/pods/pick/05-winter-specials.jpg" alt="Adding a promo category" /></p>
<p>Once our categories are added, we&#8217;ll need to add another Pick column to our original Promotions Pod:</p>
<p><img src="/images/pods/pick/06-add-category-pick.jpg" alt="Revising our Promotions Pod" /></p>
<p>The last step on the setup side of things will be to add a few promos and categorize them:</p>
<p><img src="/images/pods/pick/07-add-winter-special.jpg" alt="Adding a Winter Special" /></p>
<p>Once we have our new categorized library of promotions, we can go ahead and revise our sidebar to include only those categorized as being for the winter. To do so, we&#8217;re going to use a specific SQL syntax provided by Pods:</p>
<pre class="sh_php"><code>&lt;?php
  $promos = new Pod(&#x27;promotion&#x27;);
  $promos-&gt;findRecords(&#x27;rand()&#x27;, 1, &#x27;category.name = &quot;Winter Specials&quot;&#x27;);
  $total_promos = $promos-&gt;getTotalRows();
?&gt;

&lt;?php if( $total_promos &gt; 0 ) : ?&gt;

  &lt;?php while ( $promos-&gt;fetchRecord() ) : ?&gt;

    &lt;?php
      // set our variables
      $promo_name = $promos-&gt;get_field(&#x27;name&#x27;);
      $promo_copy = $promos-&gt;get_field(&#x27;copy&#x27;);
      $promo_link = $promos-&gt;get_field(&#x27;link&#x27;);

      $promo_link = get_permalink($promo_link[0][&#x27;ID&#x27;]);
    ?&gt;

    &lt;div id=&quot;promo&quot;&gt;
      &lt;h4&gt;&lt;?php echo $promo_name; ?&gt;&lt;/h4&gt;
      &lt;p&gt;&lt;?php echo $promo_copy; ?&gt;&lt;/p&gt;
      &lt;p&gt;&lt;a href=&quot;&lt;?php echo $promo_link; ?&gt;&quot;&gt;Find out more!&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;!-- /promo --&gt;

  &lt;?php endwhile ?&gt;

&lt;?php endif ?&gt;</code></pre>
<p>The change to notice here is the <code>WHERE</code> bit we&#8217;ve added to the <code>findRecords()</code> function call. That statement restricts the results to have a chosen category of Winter Specials in our Pick column. Tied in with the <code>ORDER BY rand()</code> snippet, we have a rotating, random, categorized set of promotions from which to pull.</p>
<p>Again, this is just a most basic implementation of relating one Pod to another, but it really opens up the door for lots of options when it comes to content management!</p>
<h4>Integration with Pods UI</h4>
<p>When writing <a href="/2010/01/04/pods-ui-intro/">Pods UI: The Latest and Greatest Addition to Pods</a> I did my best to convey how helpful <a href="http://ui.podscms.org/">Pods UI</a> is when it comes to presenting Pods to actual users. Your Pods are presented in such a way that the user recognizes the structure you&#8217;ve set up even quicker than before, and you&#8217;re able to better organize that presentation. Pick columns raise that bar even higher.</p>
<p>Before Pods UI, it was a bit cumbersome to explain how one Pod was related to another when Pick columns were involved. Now, with Pods UI, you can group related Pods into the same section in the navigation, providing a visual link between the two (or more) for the user. Circling back to our promotions example, we can now group the Promotions Pod itself alongside the Promotion Categories for easy maintenance:</p>
<p><img src="/images/pods/pick/08-pods-ui.jpg" alt="Custom Pods UI for our promos" /></p>
<p>To get this listing, simply install Pods UI, and create your own separate plugin file:</p>
<pre class="sh_php"><code>&lt;?php
/*
Plugin Name: Promotions Pods UI
Plugin URI: http://example.com/
Description: Customized Pods UI
Version: 0.1
Author: Jonathan Christopher
Author URI: http://jchristopher.me/
*/

function pods_ui_promos()
{
  $icon = &#x27;&#x27;;
  add_object_page(&#x27;Promos&#x27;, &#x27;Promos&#x27;, &#x27;read&#x27;, &#x27;promos&#x27;, &#x27;&#x27;, $icon);
  add_submenu_page(&#x27;promos&#x27;, &#x27;Promos&#x27;, &#x27;Promos&#x27;, &#x27;read&#x27;, &#x27;promos&#x27;, &#x27;promos_page&#x27;);
  add_submenu_page(&#x27;promos&#x27;, &#x27;Categories&#x27;, &#x27;Categories&#x27;, &#x27;read&#x27;, &#x27;categories&#x27;, &#x27;categories_page&#x27;);
}

function promos_page()
{
  $object = new Pod(&#x27;promotion&#x27;);
  $add_fields = $edit_fields = array(
                    &#x27;name&#x27;,
                    &#x27;slug&#x27;,
                    &#x27;copy&#x27;,
                    &#x27;link&#x27;,
                    &#x27;category&#x27;);
  $object-&gt;ui = array(
                    &#x27;title&#x27;   =&gt; &#x27;Promotion&#x27;,
                    &#x27;columns&#x27; =&gt; array(
                              &#x27;name&#x27;      =&gt; &#x27;Name&#x27;,
                              &#x27;category&#x27;  =&gt; &#x27;Category&#x27;,
                              &#x27;created&#x27;   =&gt; &#x27;Date Created&#x27;,
                              &#x27;modified&#x27;  =&gt; &#x27;Last Modified&#x27;
                              ),
                    &#x27;add_fields&#x27;  =&gt; $add_fields,
                    &#x27;edit_fields&#x27; =&gt; $edit_fields
					);
  pods_ui_manage($object);
}

function categories_page()
{
  $object = new Pod(&#x27;promotion_category&#x27;);
  $add_fields = $edit_fields = array(
                    &#x27;name&#x27;,
                    &#x27;slug&#x27;);
  $object-&gt;ui = array(
                    &#x27;title&#x27;   =&gt; &#x27;Category&#x27;,
                    &#x27;columns&#x27; =&gt; array(
                              &#x27;name&#x27;      =&gt; &#x27;Name&#x27;,
                              &#x27;created&#x27;   =&gt; &#x27;Date Created&#x27;,
                              &#x27;modified&#x27;  =&gt; &#x27;Last Modified&#x27;
                              ),
                    &#x27;add_fields&#x27;  =&gt; $add_fields,
                    &#x27;edit_fields&#x27; =&gt; $edit_fields
					);
  pods_ui_manage($object);
}

add_action(&#x27;admin_menu&#x27;,&#x27;pods_ui_promos&#x27;);

?&gt;</code></pre>
<p>Again, grouping related Pods can help <strong>exponentially</strong> when it comes to showing this new system to actual users. It reduces the learning curve quite a bit, and really helps people hit the ground running.</p>
<p>This is just the beginning when it comes to Pick columns, in future articles I&#8217;ll cover the more advanced attributes of this feature, but understanding these fundamentals will help you get started.</p>
<h4>The Pods CMS Series on <abbr title="Monday By Noon">MBN</abbr></h4>
<p>This article is the <strong>fifth</strong> in a series for Monday By Noon dedicated to <a href="http://pods.uproot.us/">Pods CMS</a>.</p>
<ol>
<li><a href="/2010/01/04/introduction-to-pods-cms-wordpress/">An Overview of and Introduction to Pods CMS for WordPress</a></li>
<li><a href="/2010/01/04/pods-basics-installation-and-setup/">Pods Basics: Installation and Setup</a></li>
<li><a href="/2010/01/04/pulling-pods-data/">Pods Basics: Pulling Pods Data to your Theme</a></li>
<li><a href="/2010/01/04/pods-ui-intro/">Pods UI: The Latest and Greatest Addition to Pods</a></li>
<li><a href="/2010/01/11/how-to-use-pick-columns-relationships-in-pods/">How to use Pick Columns (Relationships) in Pods</a></li>
<li><a href="/2010/01/25/pods-pagination-sorting/">The Last of the Pods Basics: Pagination and Sorting</a></li>
</ol>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=722&c=546046173' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=722&c=546046173' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20100111/how-to-use-pick-columns-relationships-in-pods/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 1/64 queries in 0.054 seconds using apc
Object Caching 751/830 objects using apc

Served from: www.mondaybynoon.com @ 2012-02-11 09:24:19 -->
