【发布时间】:2015-08-05 03:25:26
【问题描述】:
我正在尝试使用 flexbox 将具有 2 行网格布局的投资组合网站移植到 Wordpress,该网站以较小的分辨率包装成单列。布局类似于this portfolio site。
静态站点的代码如下所示
<div class="project-container">
<div class="project-item">
<h3 class="project-title">Project Title</h3>
<a href="#">
<img src="img/image-1500x1080.jpg">
</a>
</div>
<div class="project-item">
<h3 class="project-title">Project Title</h3>
<a href="#">
<img src="img/image-1500x1080.jpg">
</a>
</div>
</div>
我当前使用 Wordpress 循环的代码如下所示
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; endif; ?>
<?php $args=array( 'post_type'=>'work' ); $query = new WP_QUERY( $args ); ?>
<div class="project-container">
<?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<div class="project-item">
<h3 class="project-title"><?php the_title(); ?></h3>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( ''); ?>
</a>
</div>
<?php endwhile; endif; wp_reset_postdata; ?>
</div>
如何让循环显示 2 个不同的项目?
【问题讨论】: