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 trialRobin Sturgeon
3,186 PointsCustom post type not showing all posts
I have an image gallery set up through custom post type. It will only show 10 images at a time even if you enter more. Would this be an error through php or more original html?
3 Answers
Joakim Bergman
14,501 PointsWhat does your query look like? Do you have a set 'posts_per_page'. To show all posts you should use 'posts_per_page'=>-1 as the parameter in your query.
Robin Sturgeon
3,186 PointsThis is what I have
<?php
$args = array(
'post_type' => 'photos'
);
$the_query = new WP_Query( $args )
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post() ; ?>
```
Do I add the 'post_per_page' in the first query?
Robin Sturgeon
3,186 PointsI played around and got it! Thank you so much!!!
<?php
$args = array(
'post_type' => 'photos',
'posts_per_page'=>-1
);
$the_query = new WP_Query( $args )
?>
```