How to query post by pages in a <li> wordpress?


How to query post by pages in a <li> wordpress?

嗨,我是WordPress开发的新手,我只是为自己编码,你能帮我这个吗?

我想在一个li中显示我的帖子,但是li将只包含3个帖子项目。当li is已经有3个条目时它将创建另一个li所以另外3个post条目将在那里,

这是我下面的代码,它不能正常工作,但我有一个想法,我不知道如何使它的功能称为查询帖子在WordPress上的分页类型是可能的,例如,第一页将是第一个li第二页将是第二个li

                 <?php
             query_posts(array(
              'category_name' => '',
                 'post_type' => 'team',
                'posts_per_page' => 9,
                'paged' => (get_query_var('paged') ? get_query_var('paged') : 1)
            ));
            $x = 1;
            while (have_posts()) : the_post(); if ($x == 1) { ?>      
                                <li>
                                <?php } ?>
                  <div class="col-md-4 wp5">
                    <img src="<?php the_field( 'image' ); ?>" alt="Team Member">
                    <h4><?php the_field( 'name' ); ?></h4>
                    <p><?php the_field( 'intro_message' ); ?></p>
                    <div class="social">
                      <ul class="social-buttons">
                        <li><a href="<?php the_field( 'inkedin' ); ?>" class="social-btn"><i class="fa fa-linkedin"></i></a></li>
                        <li><a href="<?php the_field( 'twitter' ); ?>" class="social-btn"><i class="fa fa-twitter"></i></a></li>
                        <li><a href="<?php the_field( 'email' ); ?>" class="social-btn"><i class="fa fa-envelope"></i></a></li>
                      </ul>
                    </div>
                  </div>
                                              <?php if ($x == 3) { $x = 1; } $x++; ?>
                                </li>
            <?php endwhile; ?>

我不太确定问题是什么,但是,如果您想每个列表项只有3个团队(帖子),您的代码将看起来像这样:

             <?php
         query_posts(array(
          'category_name' => '',
             'post_type' => 'team',
            'posts_per_page' => 9,
            'paged' => (get_query_var('paged') ? get_query_var('paged') : 1)
        ));
        $x = 0;
        while (have_posts()) : the_post(); $x++; if ($x == 1) { ?>      
                            <li>
                            <?php } ?>
              <div class="col-md-4 wp5">
                <img src="<?php the_field( 'image' ); ?>" alt="Team Member">
                <h4><?php the_field( 'name' ); ?></h4>
                <p><?php the_field( 'intro_message' ); ?></p>
                <div class="social">
                  <ul class="social-buttons">
                    <li><a href="<?php the_field( 'inkedin' ); ?>" class="social-btn"><i class="fa fa-linkedin"></i></a></li>
                    <li><a href="<?php the_field( 'twitter' ); ?>" class="social-btn"><i class="fa fa-twitter"></i></a></li>
                    <li><a href="<?php the_field( 'email' ); ?>" class="social-btn"><i class="fa fa-envelope"></i></a></li>
                  </ul>
                </div>
              </div>
       <?php if ($x == 3) { ?></li><?php $x = 0; } ?>
       <?php endwhile; ?>