Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Landing Page

skyler katz
skyler katz
11,942 Points

Using the WP_Query on a custom post type stops after 10 posts

I have followed the coding examples in this video, but for some reason the loop seems to only be outputting 10 of my custom posts. I have a total of 26 posts that need to be looped through. Is the code in the video only good for 10 posts?

3 Answers

Kevin Korte
Kevin Korte
28,148 Points

Oshri Biton is correct. You can change how many posts per page show up inside of the reading settings of the WP admin. However, it depends on what your goal is. If you want all of your posts to show up everytime, you'd have to adjust this count for each post. You could also pass your WP Query an parameter in the arguments that would like like this posts_per_page => -1. This -1 value would query all of the posts onto that one page.

If you're planning on having a growing number of posts like a blog or portfolio, I can't say I'd recommend doing that though. Pagination is a good thing. If you didn't want separate "pages" you could still use pagination in an infinite scroll way. Like how Facebook or Twitter loads new items in your feed. There are multiple infinite scroll plugins that work fine.

try on wordpress admin > settings > reading > and upload the max of posts from 10 to 26.

skyler katz
skyler katz
11,942 Points

Thank you both for your help. I did not realize that custom post types would be controlled as bog post types.