gpt4 book ai didi

php - Wordpress:Php 我正在调用这个帖子,我怎么能在 3 个帖子后创建一个新的 Li 并且在它里面下一个帖子会在那里

转载 作者:行者123 更新时间:2023-11-28 05:24:16 25 4
gpt4 key购买 nike

我是 php 的新手,我对这个感到困惑;下面的代码是一个团队 slider 。在 ul 里面有一个 li 里面有 3 个 div(3 个 div 意味着 3 个人)你能检查下面我的代码并增强它吗?我对这个很困惑,我不知道该怎么做。我下面的代码只添加了新的 div(people)。我怎样才能在 3 个 div 之后使它成为可能,它会产生另一个 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>

关于php - Wordpress:Php 我正在调用这个帖子,我怎么能在 3 个帖子后创建一个新的 Li 并且在它里面下一个帖子会在那里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38879845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com