我希望数组 1,3,5,7,9 布局将从数组 0,2,4,6,8,10 反转,例如第一行布局 - 左侧的图像和右侧的描述,第二行的布局 - 图像在右边和左边的描述,并不断。
这是我的function.php代码
<?php
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
$image = get_field('featured_image', $term);
?>
<div class="row">
<div id="product-cat <?php echo $term->slug ?>">
<div class="two-col product-cat-image">
<img src="<?php echo $image ?>">
</div>
<div class="two-col product-cat-details">
<?php
echo '<h4>'. $term->name .'</h4>';
echo '<p>'. $term->description .'</p>';
echo '<a class="product-cat-button" href="' . get_term_link( $child, $taxonomy_name ) . '">See Products</a>';
?>
</div>
</div>
</div><?php
} ?>
CSS代码:
.row{
display: flex;
margin-left: -10px;
margin-right: -10px;
margin-bottom: 15px;
}
.row .col {
flex: 1;
padding-right: 10px;
padding-left: 10px;
}
结果还是这样
我的期望是这样的:
拉莫斯之舞
汪汪一只猫