簡體   English   中英

WordPress的:PHP即時通訊的職位,我怎么能使3個職位后,它將使一個新的李和里面的下一個職位將在那里

[英]Wordpress: Php im calling the post, how can i make after 3 post it will make a new Li and inside it the next post will be there

我是使用php的新手,對此感到困惑; 下面的代碼是團隊滑塊。 ul內部,它的一個li里面有3個div(3個div表示3個人),您可以在下面檢查我的代碼並對其進行增強。 我對此感到困惑,我不知道該怎么做。 我下面的代碼僅添加新的div(people)。 在3個格之后,我如何才能做到這一點呢?它將使另一個li成為內部的新一批人,

下面的代碼正在調用類別團隊,它可以調用9個項目,我想在3個項目(Div)之后實現,它將使另一個li變到里面,另外3個將到達那里。

          <div class="team-wrapper">
            <div id="teamSlider">
              <ul class="slides">
                <li>


                  <?php
                  $args = array(
                    'category_name' => 'team',
                     'post_type' => 'post',
                     'posts_per_page' => 9,
                     'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
                     );
                  query_posts($args);
                  $x = 0;
                  while (have_posts()) : the_post(); ?>       
                  <div class="col-md-4 wp5">
                    <img src="<?php the_field( 'Team_img' ); ?>" alt="Team Member">
                    <h2><?php the_field( 'Team_name' ); ?></h2>
                    <p><?php the_field( 'Description' ); ?></p>
                    <div class="social">
                      <ul class="social-buttons">
                        <li><a href="<?php the_field( 'link1' ); ?>" class="social-btn"><i class="fa fa-dribbble"></i></a></li>
                        <li><a href="<?php the_field( 'link2' ); ?>" class="social-btn"><i class="fa fa-twitter"></i></a></li>
                        <li><a href="<?php the_field( 'link3' ); ?>" class="social-btn"><i class="fa fa-envelope"></i></a></li>
                      </ul>
                    </div>
                  </div>

                <?php if ($x == 2) { echo ''; $x = -1; } $x++; ?>
                <?php endwhile; ?>

                </li>
                </ul>
                </div>
              </div>

注意:我正在使用此模板: http : //tympanus.net/Freebies/HalcyonDaysTemplate/您可以在此處下載: http : //tympanus.net/codrops/2014/07/14/freebie-halcyon-days-one -page-website-template /,您可以查看“我們是做什么的團隊”部分

尚未測試,但請嘗試以下操作:

<div class="team-wrapper">
    <div id="teamSlider">
        <ul class="slides">
            <?php
                query_posts(array(
                    'category_name' => 'team',
                    'post_type' => 'post',
                    '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 endif; ?>
                <div class="col-md-4 wp5">
                    <img src="<?php the_field( 'Team_img' ); ?>" alt="Team Member">
                    <h2><?php the_field( 'Team_name' ); ?></h2>
                    <p><?php the_field( 'Description' ); ?></p>
                    <div class="social">
                        <ul class="social-buttons">
                            <li><a href="<?php the_field( 'link1' ); ?>" class="social-btn"><i class="fa fa-dribbble"></i></a></li>
                            <li><a href="<?php the_field( 'link2' ); ?>" class="social-btn"><i class="fa fa-twitter"></i></a></li>
                            <li><a href="<?php the_field( 'link3' ); ?>" class="social-btn"><i class="fa fa-envelope"></i></a></li>
                        </ul>
                    </div>
                </div>
            <?php
                if ($x == 3) :
                    $x = 1;
            ?>
            </li>
            <?php
                  endif;
                  $x++;
            ?>
        </ul>
    </div>
</div>

按照我在共享鏈接中看到的html, 需要為ul中的每個項目創建一個li 這3項邏輯將由JavaScript驅動該插件來處理。

為了使每件物品獲得一個li,您需要將其循環到li外部而不是像現在這樣在li內部循環。

更新的代碼:

<div class="team-wrapper">
            <div id="teamSlider">
              <ul class="slides">


<?php
                  $args = array(
                    'category_name' => 'team',
                     'post_type' => 'post',
                     'posts_per_page' => 9,
                     'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
                     );
                  query_posts($args);
                  while(have_posts()){ ?>   

                <li>



                  <div class="col-md-4 wp5">
                    <img src="<?php the_field( 'Team_img' ); ?>" alt="Team Member">
                    <h2><?php the_field( 'Team_name' ); ?></h2>
                    <p><?php the_field( 'Description' ); ?></p>
                    <div class="social">
                      <ul class="social-buttons">
                        <li><a href="<?php the_field( 'link1' ); ?>" class="social-btn"><i class="fa fa-dribbble"></i></a></li>
                        <li><a href="<?php the_field( 'link2' ); ?>" class="social-btn"><i class="fa fa-twitter"></i></a></li>
                        <li><a href="<?php the_field( 'link3' ); ?>" class="social-btn"><i class="fa fa-envelope"></i></a></li>
                      </ul>
                    </div>
                  </div>

                </li>
<?php } ?>
                </ul>
                </div>
              </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM