I edit a template on WP. Faced the problem that posts are not completely removed from the portfolio category.

<?php if (have_posts()) : $count = 0; ?> <?php while (have_posts()) : the_post(); $count++; global $post; $taxo = wp_get_object_terms( get_the_ID(), 'portfoliocat');?> <!-- gallery item --> <li data-type="<?php foreach ($taxo as $taxx) { echo strtolower(preg_replace('/\s+/', '-', $taxx->slug)). ' '; } ?>" data-id="id-<?php the_ID(); ?>" class="view <?php foreach ($taxo as $taxx) { echo strtolower(preg_replace('/\s+/', '-', $taxx->slug)). ' '; } ?>"> <?php echo "count = $count"; ?> <?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-bits','portfolio-bits' ); $large = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large', false); if(has_post_thumbnail()): echo '<img src="'.$thumbnail[0].'" alt="'.get_the_title().'"/>'; else: ?><img src="<?php bloginfo('template_url'); ?>/img/gallery_sample.jpg" alt="portfolio" /> <?php endif; ?> <div class="mask"> <h4><?php the_title(); ?></h4> <a class="info" href="<?php echo $large[0] ?>" data-rel="prettyPhoto"><?php _e('+','site5framework') ?></a> </div> </li> <!-- end gallery item --> <?php endwhile; endif; wp_reset_postdata();?> 

Namely, only 9 posts are displayed. What could be the problem?

  • one
    1) In the admin there are settings for how many posts to display - Daniel
  • one
    2) make the parameter 'posts_per_page' => -1 in the request - Daniel
  • one
    You most likely take the specified number of posts per page in Настройки->Чтение . To output a different number of posts, pass a parameter before the posts_per_page with the desired number. - Nik Horse
  • one
    posts_per_page (number) The number of posts on one page. If you set -1, all posts will be displayed (without pagination). - Daniel
  • Thanks to all! It helped! - Ivan

1 answer 1

2) make the parameter 'posts_per_page' => -1 in the request - Daniel