WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 6 posts with a custom post type in my Wordpress theme. I want to show them all on a page but I can only get a maximum of 3 to show up, regardless of how many there are.

I have this code in the page:

<?php $count_posts = wp_count_posts( 'cases' )->publish;
echo $count_posts; ?>

<?php query_posts('post_type=cases'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="post" style="display:inline;">case</div>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>

...and it outputs this:

case case case

Why are my other 3 custom posts not showing up?

Thanks in advance

share|improve this question
up vote 2 down vote accepted

If you don't set a value for posts_per_page, it will use whatever the setting is for Blog pages show at most under Settings > Reading.

Also, don't use query_posts, use WP_Query instead:

$args = array(
    'post_type' => 'cases',
    'posts_per_page' => -1 // get all cases
$cases = new WP_Query( $args );
if ( $cases->have_posts() ) :
    while ( $cases->have_posts() ) :
        // output case
    // nothing found
share|improve this answer
YES! Solved. Thank you so much!!!!! – rstage Sep 22 '13 at 15:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.