I
I
ivasenkoartem2018-07-13 17:23:52
WordPress
ivasenkoartem, 2018-07-13 17:23:52

Why is WP only displaying one post?

<?php 

    // параметры по умолчанию
      $args = array(
        'numberposts' => 0,
        'category_name'    => '',
        'order'       => 'DESC',
        'post_type'   => 'post',
        'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
      );

      $category = get_the_category(); 

      $posts = get_posts( $args );

      foreach($posts as $post){ setup_postdata($post);
          // формат вывода
      }
    ?>

    <!-- single work -->
        <div class="col-md-4 <?php $category = get_the_category(); echo $category[0]->slug; ?>">
          <a href="<?php echo get_permalink(); ?>" class="portfolio_item work-grid wow fadeInUp">
            <img src="<?php the_field('привью'); ?>" alt="<?php the_title(); ?>" class="image_port">
            <div class="portfolio_item_hover">
              <div class="item_info">
                <span><?php the_title(); ?></span>
                <em><?php $category = get_the_category(); echo $category[0]->cat_name; ?></em>
              </div>
            </div>
          </a>
        </div>
        <!-- end single work -->

    <?php wp_reset_postdata(); ?>

Show only 1 post. Why? I added three

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2018-07-13
@AXP-dev

'numberposts' => -1and there will be happiness

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question