3

This is the code I have currently on my development site. It only shows 10 results from custom post type "pacificheritage" but it should show 23 all together.

<?php                   
          global $post;
          $i=1;
          $args = array(
             'order' => 'ASC',
             'orderby' => 'post_date',
             'post_status' => 'publish',
             'post_type' => 'pacificheritage'
          );
      ?>    
      <?php if (have_posts()):?>
                <?php
                $list_of_posts = new WP_Query($args); 
                while ($list_of_posts->have_posts()):$list_of_posts->the_post();
                $meta = get_post_meta( get_the_ID(), '');
                ?>
                <?php echo $post->ID; ?>
                <?php the_title(); ?><br/>
            <?php 
                endwhile;
                wp_reset_query();
                endif; 
            ?>

2 Answers 2

5

You need to add 'posts_per_page'=>'-1' to $args, so:

<?php                   
      global $post;
      $i=1;
      $args = array(
         'order' => 'ASC',
         'orderby' => 'post_date',
         'post_status' => 'publish',
         'post_type' => 'pacificheritage',
         'posts_per_page'=>'-1'
      );
  ?>    
  <?php if (have_posts()):?>
            <?php
            $list_of_posts = new WP_Query($args); 
            while ($list_of_posts->have_posts()):$list_of_posts->the_post();
            $meta = get_post_meta( get_the_ID(), '');
            ?>
            <?php echo $post->ID; ?>
            <?php the_title(); ?><br/>
        <?php 
            endwhile;
            wp_reset_query();
            endif; 
        ?>
0
1

Nats answer is great but for anyone who cant see an $args array one should look for the "posts_per_page" value in the wp_options database table. This is where all default options are set (https://codex.wordpress.org/Function_Reference/get_option) if you don't output a custom set of $args.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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