我正在尝试为我的骨骼主题wordpress站点创建一个模板,该模板具有以下网格。
GRID VISUAL
我似乎不知道如何从数据库中调用我的所有帖子,并使用我用bones CSS设置的不同模板的大量循环输出它们
查询示例:
<?php $args = array(
'post_type' => array ( 'post' ),
'post_count' => 4
);
$query = new WP_query ( $args );
if ( $query->have_posts() ) {
$count = 0;
}
?>
<section class="blog-posts grid">
<?php while ( $query->have_posts() ) : $query->the_post();
if ( get_post_type() == 'post' && $count == 0 ) {
include( locate_template( 'includes/homepage-1of2.php' ));
$count++;
}
endwhile; ?>
</section>
然后在第二次跑步时增加计数。所发生的一切就是它显示了相同的帖子(共12篇)。
提前谢谢你的帮助
编辑:
使用mtr的代码。网状物
我现在有了这个
<?php while ( $query->have_posts() ) : $query->the_post();
if ( get_post_type() == 'post') {
switch($count) {
case 0:
include( locate_template( 'includes/homepage-1of1.php' ));
break;
case 1:
include( locate_template( 'includes/homepage-1of2.php' ));
break;
case 2:
include( locate_template( 'includes/homepage-1of2.php' ));
break;
case 3:
include( locate_template( 'includes/homepage-1of3.php' ));
break;
case 4:
include( locate_template( 'includes/homepage-1of3.php' ));
break;
case 5:
include( locate_template( 'includes/homepage-1of3.php' ));
break;
default:
include( locate_template( 'includes/homepage-1of1.php' ));
}
$count++;
}
endwhile; ?>
这太棒了,很简单,但我现在需要为我所有的帖子有效地运行这个循环,所以一次又一次地重复这个6篇帖子的结构-有没有办法告诉循环运行那些模板定位器?