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 trialKatherine Delorme
795 PointsWordPress Custom Post Type Template only displaying 10 posts
Hello there,
I've done the Custom Post Type video about three times now and every time my template page displays only 10 posts out of the many more entered in the custom post type.
I'm not sure if it's an error on my end as I've followed the tutorial exact as well has done it with two other themes with different post types.
My Template page displays my post types and the content related to them but stops displaying after 10 posts. I want it so that all the post are displayed on that page. I not even able to see a section where it directs to see the rest on another page ie 'next page' 'page 2'
(Source files can be found in https://teamtreehouse.com/library/how-to-make-a-website-with-wordpress/custom-post-types-and-fields-in-wordpress/custom-post-type-templates zip folder with the templates)
If any solutions let me know please.
Thank you for your time
1 Answer
Kevin Korte
28,149 PointsAssuming you're using WP_Query
for this, try passing in 'posts_per_page' => -1
as an argument.
Katherine Delorme
795 PointsKatherine Delorme
795 PointsThank you so much it worked. YAY My only concern is how come something like next or page number didn't appear at the bottom to direct to the next page by click to see the other posts. I'm asking out of the need to learn more, sorry to further bother you after helping me with my question.
Kevin Korte
28,149 PointsKevin Korte
28,149 PointsIt won't automatically show up, you have to tell wordpress where to put the pagination links using built-in WP functions. Here is some more info how to do that.
https://codex.wordpress.org/Function_Reference/paginate_links
https://codex.wordpress.org/Function_Reference/posts_nav_link
Katherine Delorme
795 PointsKatherine Delorme
795 PointsThank you for the resource/links. I looked in the wrong area before I was stuck on trying to figure our 'wp_link_pages()' I'll go through the links. Thanks again