我想列出自定义帖子类型中的帖子,像下面的布局。自定义wordpress循环
HTML下面这样的布局。
<div class="col-md-4 col-sm-6">
PROFILE - 1
</div>
<div class="col-md-4 col-sm-6">
</div>
<div class="col-md-4 col-sm-6">
PROFILE - 2
</div>
<div class="col-md-4 col-sm-6">
PROFILE - 3
</div>
<div class="col-md-4 col-sm-6">
</div>
<div class="col-md-4 col-sm-6">
PROFILE - 4
</div>
,你可以看到后再次格分隔符 “ - - 1个& PROFILE 2 PROFILE” 后 “PROFILE - 1” 有一个div分离再有就是 “2个人 - - 1个& PROFILE”。
基本上结构如下。
资料-1
VV
空空间(DIV基于COL-MD-4 COL-SM-6)
VV
曲线-2
VV
简介-3
VV
空空间(DIV基于COL-MD-4 COL-SM-6)
VV
资料-4-
我使用该环路作为自定义结构但我无法从Profile-2> Profile-3> Space point中获取它。
寻找有助于实现这一循环
我已经试过这到目前为止
<?php
$args=array(
'post_type' => 'ourteam',
'posts_per_page' => -1
);
//Set up a counter
$counter = 0;
//Preparing the Loop
$query = new WP_Query($args);
//In while loop counter increments by one $counter++
if($query->have_posts()) : while($query->have_posts()) : $query-
>the_post(); $counter++;
//We are in loop so we can check if counter is odd or even
if($counter % 2 == 0) : //It's even
?>
<div class="col-md-4 col-sm-6">
</div>
<div class="col-md-4 col-sm-6">
<div class="cp-attorneys-style-2">
<div class="frame"> <a href="<?php the_permalink(); ?>"><?php
the_post_thumbnail(''); ?></a>
<div class="caption">
<div class="holder">
<ul>
<li><a href="<?php the_field('mem_twitter'); ?>"><i class="fa fa-twitter"></i></a></li>
<li><a href="<?php the_field('mem_facebook'); ?>"><i class="fa fa-facebook"></i></a></li>
<li><a href="<?php the_field('mem_linkedin'); ?>"><i class="fa fa-linkedin"></i></a></li>
</ul>
<p> </p>
<a href="<?php the_permalink(); ?>" class="btn-style-1">Read Profile</a> </div>
</div>
</div>
<div class="cp-text-box">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<em><?php the_field('mem_titles'); ?></em> </div>
</div>
</div>
<div class="col-md-4 col-sm-6">
</div>
<?php
else: //It's odd
?>
<div class="col-md-4 col-sm-6">
<div class="cp-attorneys-style-2">
<div class="frame"> <a href="<?php the_permalink(); ?>"><?php
the_post_thumbnail(''); ?></a>
<div class="caption">
<div class="holder">
<ul>
<li><a href="<?php the_field('mem_twitter'); ?>"><i class="fa fa-twitter"></i></a></li>
<li><a href="<?php the_field('mem_facebook'); ?>"><i class="fa fa-facebook"></i></a></li>
<li><a href="<?php the_field('mem_linkedin'); ?>"><i class="fa fa-linkedin"></i></a></li>
</ul>
<p> </p>
<a href="<?php the_permalink(); ?>" class="btn-style-1">Read Profile</a> </div>
</div>
</div>
<div class="cp-text-box">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<em><?php the_field('mem_titles'); ?></em> </div>
</div>
</div>
<?php
endif;
endwhile; wp_reset_postdata(); endif;
?>
的全部价值? –
@ hardik solanki我有更新我的问题,请参阅 – greenarrow
默认情况下,引导使用了12列结构。如果你使用'col-md-4 col-sm-6',那么它将在Ipad中显示3个div和2个div。所以在你的情况下,它会像你的截图一样显示。 –