是的,有点不清楚,但我想我理解你想要实现的目标。这很可能是由于css的缘故。可以使用CSS3伪选择器将其作为目标
.sidebar a { float: left; }
.sidebar a:nth-child(4n-0) { clear: left; }
或。。这可能有用,但没有承诺,因为我看不到你的css。
if(is_category()) {
$thiscat = get_term( get_query_var(\'cat\') , \'category\' );
$subcategories = get_terms( \'category\' , \'parent=\'.get_query_var(\'cat\') );
$items=\'\';
$breakpoint = 1;
if(!empty($subcategories)) {
$items .= \'<div class="sidebar">\';
foreach($subcategories as $subcat) {
if($thiscat->term_id == $subcat->term_id) $current = \' current-cat\'; else $current = \'\';
$items .= \'<span class="sidebar_content"><a href="\'.get_category_link( $subcat->term_id ).\'" title="">\'.$subcat->name.\'</a></span>\';
if($breakpoint %3 != 0 && $breakpoint != count($subcategories) ) {
$items .= \'</div><div class="sidebar">\';
} elseif($breakpoint == count($subcategories)) {
$items .= \'</div>\';
}
$breakpoint++;
}
echo $items;
}
unset($subcategories,$subcat,$thiscat,$items);
}