我正试图让我的自定义税务术语网格在我的第四列之后中断(插入一个clearfix)。下面是我的代码。在使用类似于所演示的技术之前,我已经看到并完成了这项工作at this link. 然而,我没有使用传统的循环,所以我真的不知道如何实现它。期待您的反馈。
下面是Josh Mountain建议的代码。断裂未出现在正确的位置。我还附上了一个屏幕截图,显示了我正在努力实现的目标以及当前的结果。
以下代码更新于20年8月19日1:51 cst。
<div class="row">
<?php
$libargs=array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 0,
\'exclude\' => array(16, 20, 22,25, 27, 28, 30, 4, 42, 7, 43 ), //* Enter ID\'s of parent categories to exclude from list
\'taxonomy\' => \'100list\',
\'parent\' => \'\',
);
$libcats=get_categories($libargs);
$i = 0;
foreach($libcats as $lc){
$i++;
if( $i % 4 == 0 ) {
echo \'<div class="clearfix"></div>\';
}
echo \'<div class="col-lg-3 col-md-4 col-sm-6 col-xs-6 ">\';
$termlink = get_term_link( $lc->slug, \'100list\' );
?>
<div class="thumbnail">
<div class="caption">
<br/><br/>
<h1><span class="label label-warning"><?php echo $lc->count ?></span></h1>
<p> Symbols </p>
<p> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </p>
<!-- basic text field display start -->
<p> <?php the_field(\'basictext\', \'100list_\'.$lc->term_id); ?></p>
<!-- basic text field display end -->
</div>
<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field(\'taximage\', \'100list_\'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, \'industrygroup-img\');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php
}
}
?>
<!-- Get Image by Attachment ID End-->
</div>
<small><p class="text-center"> <a href="<?php echo $termlink; ?>"> <?php echo $lc->name; ?></a> </p> </small>
<?php echo \'</div>\'; }?>
</div>
最合适的回答,由SO网友:Josh Mountain 整理而成
我不太确定您希望clearfix进入何处,但您应该能够这样做:
<div class="row">
<?php
$libargs=array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 0,
\'exclude\' => array(16, 20, 22,25, 27, 28, 30, 4), //* Enter ID\'s of parent categories to exclude from list
\'taxonomy\' => \'industrygroups\',
\'parent\' => \'\',
);
$libcats=get_categories($libargs);
$i = 0;
foreach($libcats as $lc){
if( $i % 4 == 0 ) {
/* INSERT CLEARFIX STUFF */
}
$i++;
echo \'<div class="col-lg-3 col-md-4 col-sm-6 col-xs-6 ">\';
$termlink = get_term_link( $lc->slug, \'industrygroups\' );
?>
<div class="thumbnail">
<div class="caption">
<br/><br/>
<h1><span class="label label-warning"><?php echo $lc->count ?></span></h1>
<p> Symbols </p>
<p> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </p>
<!-- basic text field display start -->
<p> <?php the_field(\'basictext\', \'industrygroups_\'.$lc->term_id); ?></p>
<!-- basic text field display end -->
</div>
<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field(\'taximage\', \'industrygroups_\'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, \'industrygroup-img\');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php
}
}
?>
<!-- Get Image by Attachment ID End-->
</div>
<small><p class="text-center"> <a href="<?php echo $termlink; ?>"> <?php echo $lc->name; ?></a> </p> </small>
<?php echo \'</div>\'; }?>
</div>