我列出了自定义分类名称。列表正在显示,表结构为:
<table>
<tr>
<td>Name 1</td>
<td>Name 2</td>
<td>Name 3</td>
<td>Name 4</td>
</tr>
<tr>
.....
</table>
第四个名字不显示,跳到第五个。如果我不使用第二个循环,下面列出的所有分类法都是我的代码:
<?php
// no default values. using these as examples
$i = 0;
$taxonomies = array( \'urun-kategorileri\' );
$args = array(
\'orderby\' => \'menu-order\',
\'order\' => \'ASC\',
);
$tax_terms = get_terms( $taxonomies, $args );
echo \'<table class="table table-hover"><tr>\';
foreach( $tax_terms as $tax_term ) { {
$i++;
if( $i <= 4 ) {
echo \'<td><a href="\' . esc_attr( get_term_link( $tax_term, $taxonomy ) ) . \'" title="\' . sprintf( __( "Profilleri Görüntüle %s" ), $tax_term->name ) . \'" \' . \'>\' . $tax_term->name . \'</a></td>\';
echo ("\\n");
}
else {
echo \'</tr><tr>\';
$i = 0;
}
} }
?>
</table>
SO网友:simandir
每个循环的Solvedi已更改
<?php
$taxonomies = array(
\'urun-kategorileri\',
);
$args = array(
\'orderby\' => \'menu-order\',
\'order\' => \'ASC\',
);
$tax_terms = get_terms($taxonomies, $args);
echo \'<table class="table table-hover"><tr>\';
foreach ($tax_terms as $tax_term) {
echo \'<td><a href="\' . esc_attr(get_term_link($tax_term, $taxonomy)) . \'" title="\' . sprintf( __( "Profilleri Görüntüle %s" ), $tax_term->name ) . \'" \' . \'>\' . $tax_term->name.\'</a></td>\';
echo ("\\n");
$counter++;
if ($counter % 4 == 0) {
echo \'</tr>\';
}
}
?>
</table>