Build Your Own Business Website header image

Community Library Case Study – Part 48, Increase the Number of Posts that Display on the Custom Catalog

Difficulty Level -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

This is the forty eighth in a series of live lessons on using WordPress and Thesis as a Content Management System (CMS). In this lesson we change the display of posts so that any post that meets the right criteria for the recent posts category will show. Currently only 20 posts are being displayed. We fix this by adding the posts_per_page parameter to our custom loop and set it to -1 so that all posts that meet the criteria will show.

Community Library Website – Case Study Part 1 – Site Organization
Community Library Website – Case Study Part 2 – Create Custom Post Types
Community Library Website – Case Study Part 3 – Custom Post Type Configuration
Community Library Website – Case Study Part 4 – Custom Taxonomy Decisions – Theory
Community Library Website – Case Study Part 5 – Custom Taxonomy Decisions – Practical Application
Community Library Website – Case Study Part 6 – Incorporating Existing Data Into the Project
Community Library Website – Case Study Part 7 – Creating Hierarchical Custom Taxonomies
Community Library Website – Case Study Part 8 – Creating Non-Hierarchical Custom Taxonomies
Community Library Website – Case Study Part 9 – Creating Custom Post Meta
Community Library Website Case Study – Part 10a – Restore the Database Using BackupBuddy
Community Library Website Case Study- Part 10 – Creating Custom Post Meta – Continued
Community Library Website – Part 11 – Importing Existing Data to the Website
Community Library Website – Part 12 – Prepare Existing Data for import by the CSV Importer plugin
Community Library Website – Part 13 – Import Existing Data Using the CSV Importer Plugin
Community Library Website – Case Study Part 14 – Date in Permalink Configuration
Community Library Website – Part 15 – Importing Images
Community Library Website – Part 16b – Final Data Import
Community Library Website – Part 17 – Add Thesis Post Meta to Custom Post Type
Community Library Website – Part 18 – Add WordPress 3.0 Menus
Community Library Website – Part 19 – Add Post Meta and Taxonomy Information to the Post Display
Community Library – Part 20 – Add topics and audience to book display
Community Library – Part 21 – Display the Rest of the Post Meta in the Post
Community Library Website – Part 22, Create the Permalink Structure
Community Library – Part 23 – Remove Custom Post Meta from Post Display
Community Library Website – Part 24, Add Taxonomy and Post Meta Data to the Teaser
Community Library Website – Part 25, Add Taxonomy Data to the Teaser
Community Library Website – Part 26, Adjust the Teaser Styling Using Design Options
Community Library Website – Part 27, Styling the Teaser Using CSS
Community Library Website – Part 28 – Fine Tune the Teaser Display
Community Library Website – Part 29, Designing a Custom Catalog Page
Community Library Website – Part 30, Using a Query String in a URL
Community Library Website – Part 31, Adding Custom WordPress Menus
Community Library Website – Part 32, Add Custom Menus to the Catalog Page
Community Library Website – Part 33, Add Another Custom Menu to the Catalog Page
Community Library Website – Part 34, Troubleshooting Custom Menus
Community Library Website – Part 35, Add Styling to WordPress Menus
Community Library Website – Part 36, Add HTML Markup to WordPress Menus
Community Library Website – Part 37, Add WordPress Menus to Archive Pages
Community Library Website – Part 38, Add and Style a List of Tags
Community Library Website – Part 39, Add a Search Box to the Sidebar
Community Library Website – Part 40, Add Links to the Sidebar
Community Library Website – Part 41, Add Taxonomy Drill Down Browsing
Community Library Website – Part 42, Custom Loop to Display Custom Post Types
Community Library Website – Part 43, Simple Custom Query
Community Library Website – Part 44, Custom Taxonomy Query
Community Library Website – Part 45, Add Thesis HTML Structure to Teasers
Community Library Website – Part 46, Display Posts from the Last 60 Days
Community Library Website – Part 47, Custom Loop If Have Posts
Community Library Case Study – Part 48, Increase the Number of Posts that Display on the Custom Catalog
Community Library Website – Part 49 – Naming Conflicts in Custom Taxonomies
Community Library Website – Part 50 – Find and Replace Semi-colons in the Database
Community Library Website – Part 51 – Modify Taxonomy Names Directly in the Database
Community Library Website – Part 52 – Sort Posts by Meta Value
Community Library Website – Part 53 – Show the Term Label Only when a Term Exists
Community Library Website – Part 54 – Sort Archive Posts by Meta Value
Community Library Website – Part 55 – Add Sort Order to Custom Taxonomy

Video Transcript

Rick: And let’s see, so… and Pam asked about pagination on the Community Library site. Let’s go there real quick. Go to custom catalog page and… oh, I forgot. We didn’t go through how to style these things either did we? I checked that off my list but obviously, we didn’t. So we’ll take on that tonight too but let’s see. Pam, I’m going to turn your microphone back on here. Hi Pam.

Pam: Good morning, Rick.

Rick: So I think what you were asking me was that in the biography section, a maximum of 20 are going to show up when… for these you know, recent biographies and if there’s more than 20, you want to paginate. You want to go to previous posts, is that right?

Pam: Yes. While we’re looking at the recent post here, if there’s more than about 20, right now, I’m not seeing any pagination at the bottom so you can see the rest of them.

Rick: And when you say more than 20, you’re referring to more than 20 per section, right?

Pam: No, just the whole thing. If we’re just talking about the recent posts that are the default for this page, it does not show all of them because after you get to about 20 of them, there’s no pagination at the bottom. Instead, it’s just telling you that there’s all there are when in fact there might be more.

Rick: Okay well that is a code fix that we’ll have to do. You can’t really do pagination that way. What we have to do is we have to fix the code so that it doesn’t stop at 20. So that it shows every post that meets the criteria, right? Every post that is within the last 60 days shows up period, even if there was 100 of them.

Pam: That would be fine, yes.

Rick: And that’s what we need to do because what this really comprised of is several loops, right? A loop essentially for each category and each of those… and if a category doesn’t have anything in it then it doesn’t show up. There’s no way to paginate that. And so, it’s not… so we can’t paginate. What we have to do is we have to fix the code and I think the way we’ll fix that code… just see if we can do that quickly right now. We’re going to open our file and let’s see… okay. No, it’s not tutorial site. Here we go. Library…

So let’s see, where is our custom… okay. So here we have it and what we would do with this is say post to show… yeah, okay. So there’s the end of the taxonomy query so I need to come down here one more time and say… it’s not post to show. It’s post per page and then I believe it’s – 0 is the right code. Post per page – 0 which means it will show everything. We could also just say post per page 100, right? And assuming that you’re never going to have 100 books come in in 60 days or that – 0… let’s just try the – 0 for a second and make sure it doesn’t crash the site. I think that’s the right… well actually, why don’t we just look at that.

If we go to the… www…let’s see. So we’re going to search for WP query and that is in the codex and we look at paging parameters, pagination parameters. So post per page… oh it’s – 1. That’s what it is. To show all posts, it’s – 1 not – 0. So – 1 would then show as many posts as met the criteria. So you noticed that when we added this additional option to this array you know, we put another… we put a comma after this tax query because that’s one element of that array. Put a comma after it and then put our… the next element of the array which is the one we just created. And then the last one doesn’t actually require a comma.

So now, our argument has 3 primary query elements. It’s got post type, it’s got the taxonomy query, and it’s got post per page. Does that make sense?

Pam: Yes.

0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
THIS IS A LIMITED TIME OFFER!
Subscription Options
0 comments… add one

Leave a Comment