The Last of the Pods Basics: Pagination and Sorting

Posted: January 25, 2010 Comments(55)

NOTE: This tutorial series is extremely out of date, please see

The Series on Pods has been quite a success so far. I’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’m super happy about that, and I’d like to close out the initial push on the series with what I’ll call The Last of the Pods Basics. That is to say, I’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.

As a quick recap, if you haven’t read the first five articles in The Series, you will probably find this article a bit confusing. That said, please make sure you’ve read: An Overview of and Introduction to Pods CMS for WordPress, Pods Basics: Installation and Setup, Pods Basics: Pulling Pods Data to your Theme, Pods UI: The Latest and Greatest Addition to Pods, and How to use Pick Columns (Relationships) in Pods. Being up to speed is essential with this article, as it’s going to build on the system we’ve put in place using the previously published articles. You won’t need to recreate the structure set up in the earlier walk throughs, but knowing the existing implementation will help these instructions remain clear.

Paginated content in Pods

Pods comes with pagination built right in, it’s just a matter of getting it to work the way you want. We’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 Pods UI to help manage the content.

Our new Team listing

If we were to check out our Team page now, we’d see that the listing has been limited to the default 15 records:

Team listing

Also by default, Pods doesn’t include any sort of warning that content wasn’t listed. It shouldn’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’re using:

  $team = new Pod('team');
  $team->findRecords('name ASC');

As it turns out, findRecords has more parameters to work with, one of which is the LIMIT we want to use. You can change the default of 15 by defining the $rows_per_page parameter:

  $team = new Pod('team');
  $team->findRecords('name ASC', 20);

If we were to make that change, we’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’ll revert back to the default limit of 15, and include our pagination links below the Team listing. It’s even easier than it sounds. After you’ve defined your Pod, you can fire the following anywhere:

<?php echo $team->getPagination(); ?>

getPagnination() basically takes care of everything, and will include the pagination controls where echo‘d:

Pagination controls

Here’s the best part, that’s all you’ve got to do. Clicking the second page appends a couple of $_GET variables, reloads the page, and shows you all of your new data. You’re done. There are a few more details concerning getPagination() which will be covered in a subsequent article.

Sorting Pods entries

I’m really excited that the Pods developers are taking so much care with Pods UI. Beyond the inherent user experience improvements it makes, they’re adding features that you can’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 number 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 Pods UI. As with every other aspect of Pods, it’s super easy to integrate, we’ll walk through it quickly.

The first step carries over from the old way of doing things, you’ll need to add a number column to your Pod. We’ll continue working with our Team Pod:

Adding our number column

Once the column is added, we’re going to need to modify our theme template to ORDER BY that column as opposed to the name column it’s currently using:

  $team = new Pod('team');
  $team->findRecords('displayorder ASC');       
  $total_members = $team->getTotalRows();

Easy enough. You could actually leave things as is, and your user could manually edit each of the displayorder columns for each Pod entry, but Pods UI makes that so much easier. We’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 revised plugin is as follows:

Plugin Name: Team Pods UI
Plugin URI:
Description: Customized Pods UI
Version: 0.1
Author: Jonathan Christopher
Author URI:

function pods_ui_team()
  $icon = '';
  add_object_page('Team', 'Team', 'read', 'team', '', $icon);
  add_submenu_page('team', 'Team', 'Team', 'read', 'team', 'team_page');

function team_page()
  $object = new Pod('team');
  $add_fields = $edit_fields = array(
  $object->ui = array(
        'title'   => 'Team',
        'reorder' => 'displayorder',
        'reorder_columns' => array(
             'name'      => 'Name',
             'position'  => 'Position'),
        'columns' => array(
             'name'      => 'Name',
             'position'  => 'Position',
             'created'   => 'Date Created',
             'modified'  => 'Last Modified'
        'add_fields'  => $add_fields,
        'edit_fields' => $edit_fields



While it looks very similar to the Pods UI plugin we developed earlier, you’ll want to note the subtle difference:

'reorder' => 'displayorder',
'reorder_columns' => array(
     'name'      => 'Name',
     'position'  => 'Position'),

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’s quite simple. You define reorder with the number column you set up and would like to use to control the sort order, and reorder_columns 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:

Our new Reorder button

Clicking that button will reload the page and bring the user to a page dedicated to managing the order of the Pods entries:

Our new Reorder page

Beautiful! 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.

Pods never disappoints

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, and thought into the implementation and I can’t thank them enough. If you’ve found yourself embracing Pods, please take a moment and donate to the project as I know for a fact they’re working night and day to make Pods that much better with every release.

The Pods CMS Series on MBN

This article is the sixth in a series for Monday By Noon dedicated to Pods CMS.

  1. An Overview of and Introduction to Pods CMS for WordPress
  2. Pods Basics: Installation and Setup
  3. Pods Basics: Pulling Pods Data to your Theme
  4. Pods UI: The Latest and Greatest Addition to Pods
  5. How to use Pick Columns (Relationships) in Pods
  6. The Last of the Pods Basics: Pagination and Sorting

Get my newsletter

Receive periodic updates right in the mail!
  • This field is for validation purposes and should be left unchanged.


  1. Thank you Jonathan for writing this series. Although I was using Pods CMS and Pods UI before I found your posts, this was a good back to basics and from the ground up teaching. And it even showed me some stuff I didn’t know about. I can honestly say that I’m now a more efficient Pods CMS and Pods UI user!

  2. I tried Pods a while back and found it quite interesting. However, the big problem for me is that it kind of sits “on top of” and “aside” from the core WP functionality.

    What I mean is this: you can’t use popular plugins on Pods pages (for example, maybe you want to add Wp_Polls to a Pod page) and it doesn’t integrate with other built in WordPress features such as Search — there’s no out of the box way of having a search on your site that will search the WP data AND the Pods data.

    Sure, you can program all this stuff if you have time time, knoweldge and inclination, but it’s a lot of effort and many who are using WP to build sites don’t have “proper” programming knowledge. For this reason, I think if you’ve got to the point with customising WordPress where Pods is your next step, I really think you should be using a more appropriate system in the first place, such as Expression Engine. At the end of the day, WP core isn’t really built to be a flexible CMS and while I really do applaud the Pods team for an amazing plugin, it just feels like yet another “hack” to make WP do something clever.

    It’s kinda pointless trying to fit a square peg into a round hole. Get hold of the round peg to begin with.

    Of course, I’m a bit out of date with my Pods knowledge, so if some of these problems have now been addressed, perhaps it does make the system more viable? I’d be interested to know.

  3. I don’t understand how I can include

    $team = new Pod(‘team’);

    in say, footer.php. I get an error that the class “Pod” is not found.

  4. Yes Pods is installed and working just fine. Basically I want to display sponsor images in footer.php of my template. I defined a sponsors pod and now I want to use it on my template page.

    findRecords(‘displayorder ASC’);
    $total_members = $sponsors->getTotalRows();

    0 ) : ?>
    fetchRecord() ) : ?>

    $sponsor_name = $team->get_field(‘name’);
    $sponsor_photo = $team->get_field(‘image’);
    $sponsor_url = $team->get_field(‘url’);
    <div class="sponsor" id="sponsor_”>
    <a href="” target=”_blank”><img src="” alt=”” />

    Do I need to do a require_once and point it to pods/core/Pod.class.php? I tried that and I get a fatal error on sanitize().

  5. Ok so I figured it out, I did end up using require_once and it worked. The problem was not changing
    $sponsor_name = $team->get_field(β€˜name’);

    $team should be $sponsors

    I think if possible maybe note that using a line like

    require_once(WP_PLUGIN_DIR . ‘/pods/core/Pod.class.php’);

    when using Pods in a WordPress template file.

  6. What would be the easiest way to display a team profile photo in the Pods UI column?

  7. So two questions for you all. First, how would you sort the ‘Name’ column based on the displayorder and not alphabetically? If you notice that it flips order when you do reorder. My users are confused because they expect things to be in the same order from the Manage to Reorder pages.

    Also, how about displaying a thumbnail in the table? Is there a way to intercept the table builder to insert an image tag, or somehow use a display helper for it?


  8. Your concerns are definitely valid, Matt. I’ve developed a, for lack of a better word, theory on integrating Pods while keeping in line with WordPress’ intended functionality but you’re right: there’s a point where the two simply don’t gel as originally intended. What’s great though, is that the Pods devs have done everything they can to mimic that functionality by implementing things like pods_navigation() to use in conjunction with the WordPress functions we all know and love. It’s a it more work, sure, but the stone has been laid.

    It sounds like you’re a seasoned EE developer, and when it comes down to it, it’s about finding the right tool for the job. Many EE devs feel that WordPress pigeonholes a website into a blog-oriented platform and that’s a stigma WordPress will deal with likely for the rest of its life. Personally, I think WordPress is much more friendly for the end user, and if it takes a small bit of creativeness on the development end, that’s okay (for the most part). The end goal is to have the best platform for our clients to use, and if everything you implement on the WordPress end is totally janky, ExpressionEngine would have probably been a better choice.

    Thanks so much for your thoughtful response!

  9. Jonathan,

    I’ve been developing websites with WP for only 1 year and it’s the platform I want to master. Recently I’ve been studying ways to make WP work more like a CMS and came across several plugins (More Fields, Custom Field Template, Flutter, CMS Press and Pods CMS). I guess Pods is the winner after reading your tutorial series. So I’ll try to implement it on my company’s new portfolio website. But I have a doubt.
    I’m intending to use picasa for storing and managing each job’s album of pictures and video. WP has a plugin that handles this quite nicely called Shashin. This plugin lets me add thumbnails of a picasa album to a post using a lightbox javascript to zoom in. Do you think it’s possible to integrate this functionality in a Portfolio Pod? Shashin supports shortcodes. ex: [sthumbs=10|8|7|6|5|4|3|2|1,max,3,n,center,]

  10. Hey Jonathan,
    Thank you for this intro to Pods… I’ve been meaning to look into it and really found your articles to be very easy to digest. You gave just the right amount of info with great examples.
    Thanks again!

  11. Integrating with another Web service is absolutely within the realm of Pods! I would suggest hopping on the forum and putting out a request for some help if you’re thinking of heading in that direction.

  12. Hey boys,
    I wanna do exactly the same. I wrote your line Todd right here in the team_page()-function:
    $object = new Pod(‘showcase’);
    $object->findRecords(‘displayorder ASC’);

    But it has no effect πŸ™ the order stays alphabetically. What do I wrong?

  13. Thanks Jonathan for a great intro to Pods. I had never heard of it just one hour ago, although I’ve been building a few websites in WordPress for about 9 months now. I will look for ways that I might be able to use it on upcoming projects. When I do I’ll be back to study your tutorial again. Anyhow, just wanted to say many thanks for taking the time to create such a great tutorial on the subject.

  14. Hi Jonathan,

    These articles have been indispensable, especially the info on sorting. I’m wondering how this functionality could be used inside a pod entry. For example, I have a pod that can create slideshows in shadowbox. Many images can be associated with a slideshow, but I can’t seem to figure out how to reorder images once they have been uploaded. I’d like to be able to resort them rather than having to “x” them out and add them back in the new order. I can sort the entries in a pod fine now, thanks to you, but can’t seem to figure this out…

    Or maybe this sort of thing just supposed to be handled by an input-manager?

    In any case, it would be great to hook into something already there!

  15. Yo Jon.. this is the 3rd time I try to post this. Last try. Maybe something with your comment-function isn’t alright.

    I found an easier way which worked for me, I just added the key-value-pair “‘sort’ => ‘displayorder ASC'” into the $object->ui – Array, and it works just fine πŸ™‚

  16. I would like to second James’ question for sorting within a pod entry.

    Also i just figured your sorting method to be only available to the pod admin. Where can I enable other authors to re-order the items?

  17. Hi Jonathan,
    Your articles are excellent. Thank you very much.
    Is there any way to add column types like radiobox, checkbox list while adding column in Pods ?

  18. Jonathan,
    this resource is fantastic. The Pod CMS plugin seems just what I need to create a mortgage site.
    I feel that these tutorials could be even better for non technical people like myself if you actually showed the result of the tutorial. That is the page on the front-end of the WordPress. It would help me visualise how it works.
    Thanks once again.

  19. Johnathan, thank you for sharing your totally awesome tutorials. I’m somewhat of a nube to WP but quickly learning my way around, and your tutorials are helping in a big way. It’s the generosity of skilled developers, such as yourself, that makes open source such a good thing for everybody.

    But speaking of generosity and giving back to the community, Matt Hill’s comparison of WP + Pods to Expression Engine fails to point out one very important aspect about EE. Namely, it is a commercial product which is prohibitively expensive for many (probably most) WP users. Even their non-commercial license (personal, not-for-profit, etc..) is a whopping $149. Their commercial license is $299 for a single domain, and another $199 for their muti-site addon, which appears to be required even for subdomains. The lowest priced license is $99, which is for a single freelancer website (limit 3 users), which is presumably to sell yet more licenses. You can find their pricing overview at

    Sorry to barge in with this off-topic information, but in all fairness I feel this should at least be mentioned.

  20. Jonathan, is Pods for me?
    I’m looking for a solution to set up my WP site. Maybe I need BP?
    I need for people who register on my site to get their own Biography page where they can fill in their info in various text areas as well as display thumbs of pictures they’ve uploaded.
    On a gallery page with representative thumbs of my registrants in alphabetical order, I want the general public to be able to click on a thumb that takes them to the registrants bio page so they can find out more about that person.
    Without being a programmer, I ‘m looking for a way to handle this. I’m searching all the plugins and I THINK Pods seems like it will do all this. I’d appreciate your guidance.

  21. Hi Jonathan, I just got through reading the entire series and would like to thank you for your effort. You’re a pretty good salesman for Pod.

    It would be nice to see an article that covers drawbacks or limitations to using Pods. It’s great to learn what can be done, but it would also be good to know what’s not possible (such as integrating search and some of the points that Matt mentioned above).

  22. I just today -really – cracked UI, and couldn’t be more pleased. Thank you thank you thank you.

    I wonder if it’s possible to reorder only a specific selection of your data– in your example, I only want to show team members where position=employee. I’m looking at the $object->ui setup, and it doesn’t seem likely, but thought I’d ask…

  23. Hi and thank you for this! I’ve updated to latest wordpress and pods also installed pods ui and I think I am lost. This drag and drop feature is great and would love to be able to use it. I was wondering if this has been built into the latest pods update, seems like a much needed necessity. Thank you again for the tutorials!

  24. Greetings!

    I love your tutorials! They’ve been a great help!

    However, I’m using the newest release of PODS on a site of mine, and I’m just wondering, since PODS UI is already bundled with PODS itself, I can’t seem to find the file that you’re talking about in this tutorial. When I go to the “Ui” folder in the plugin folder for PODS, there’s a bunch of different files there and I’m not sure which one I should be editing exactly.

    Could you help me figure this one out? Help is greatly appreciated!

  25. I believe Yennan was looking for a separate Pods UI plugin, but that’s now delivered with Pods as opposed to a separate install. When writing the custom Pods UI setup for your current theme, you can make a new plugin for that code or alternatively you can insert it into your functions.php.

  26. Thanks for your answer Jonathan.

    I did tried it, but, it seams it created a new similar pod, but without the fields i have added.
    I am a bit confused about this plugin, although it’s a definite improvement, to be able to easily order elements.

    Any suggestions?

  27. Hi Jonathan, need your help again here, i just managed to create Pods UI, and now trying to have the reorder function, and i’m quite sure that i have put the right script, but error still occurs, here’s the error message:

    SQL failed; SQL: SELECT SQL_CALC_FOUND_ROWS DISTINCT `t`.*, `p`.`id` AS `pod_id`, `p`.`created`, `p`.`modified` FROM `wp_pod` AS `p` INNER JOIN `wp_pod_tbl_t_promotion_category` AS `t` ON `t`.`id` = `p`.`tbl_row_id` WHERE `p`.`datatype` = 3 ORDER BY `t`.`displayorder` LIMIT 0,1000; Response: Unknown column ‘t.displayorder’ in ‘order clause’

    Any ideas?

  28. Ah yessss.. at last, thank you… i missed one column there, so yes, you are correct, it bring me to the error.

    Thank you again.

  29. Thanks for your articles on Pods, Jonathan, they’re really appreciated, especially for someone like me that is easily overwhelmed with new stuff! It might be because I’m overtired, though, but I’m confused about something that ought to be simple.

    The pagination section at the top of this article is all about the site’s front end – showing returned records for the general public. But then the sorting part seems to be about PodsUI, which is just a back-end feature, is that right? I’ve got UI working out and it’s already making my life more pleasant. But what I’m really after, and it’s the thing that’ll make all my dreams come true, is UI-like multi-column sorting on the front end. I want to present a list of records to the public and to have them be able to sort ASC or DESC according to, say, ID or surname, or town, by clicking on front end column headings. Given that I can do it via the backend, it seems like it should be possible to also do this via the front-end too – after all, it’s just code, and the code’s there somewhere., right? Am I missing something incredibly obvious? Do I need to start poking around inside ajax files (please don’t make me!)

    thanks as always,

  30. Yes, you’re correct in saying that the first part of the article discusses pagination on the front end, and the sorting takes place via Pods UI on the back end. I do have a bit of bad news for you regarding your next steps. It’s going to be (more or less) quite a manual process to accomplish the task you’ve outlined. While in the admin, the tables are built already, abstracting that out of Pods UI and into your own implementation will be a bit of work. Pods UI is quite an elaborate piece of code, have a look at pods/pods-ui.php and you’ll see what I mean. That’s the file that’s building everything you see in the admin system and accounts for just about every option under the sun.

    I don’t want to leave you hanging but don’t want to offer false hope either. I would recommend building things by hand and simply modifying the Pods request using any combination of $_GET variables you need to accomplish sorting. Alternatively, depending on how elaborate you’d like your implementation, it might be worth exploring JavaScript table sorting plugins that would help if the data set is smaller, and sorted links don’t need to be shared around.

    Hope that helps a bit!

  31. Thanks for the prompt response, Jonathan. What started off as an awful sinking feeling when I got to the ‘I do have a bit of bad news for you regarding your next steps.’ bit has turned into relief and pride, as I’ve now managed to cobble together a primitive but perfectly workable system through the use of pods_url_variable. I can’t believe I’ve only just realised what pods_url_variable actually does!

    Thanks again.

Leave a Reply

Your email address will not be published. Required fields are marked *