使用twitter bootsrap,如果在同一位置有更多的小部件,我想对我的小部件进行网格化。我的意思是:拥有一个注册的小部件
register_sidebar(array(
\'name\' => __(\'Footer Top\', \'roots\'),
\'id\' => \'footer-top\',
\'before_widget\' => \'<div class="footer_teaser %1$s %2$s">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3>\',
\'after_title\' => \'</h3>\',
));
如何计算和循环列中的所有小部件?假设理论上,我在给定位置有3个(这是可变的)小部件,而不是将其拆分为12/3(或另一个已计数),这将为我提供上述示例
footer_teaser col-sm-4 col-md-4
比预期的结果会产生
<div class="footer_teaser col-sm-4 col-md-4">
<h3>About us</h3>
<p>Fugiat dapibus, tellus ac cursus commodo, mauesris condime ntum nibh, ut fermentum mas justo sitters.</p>
<p><i class="fa fa-map-marker"></i> 3 Athens street</p>
<p><i class="fa fa-phone"></i> (+30) 265-9987</p>
<p><i class="fa fa-print"></i> (+30) 9854-7855</p>
<p><i class="fa fa-envelope"></i> [email protected]</p>
</div>
到目前为止,我在计算小部件时发现了什么
function count_sidebar_widgets($sidebar_id, $echo = true) {
$the_sidebars = wp_get_sidebars_widgets();
if (!isset($the_sidebars[$sidebar_id]))
return __(\'Invalid sidebar ID\');
if ($echo)
return 12 / count($the_sidebars[$sidebar_id]);
else
return count($the_sidebars[$sidebar_id]);
}
比我这一代人
register_sidebar(array(
\'name\' => __(\'Footer Top\', \'roots\'),
\'id\' => \'footer-top\',
\'before_widget\' => \'<div class="footer_teaser col-lg-\'.count_sidebar_widgets(\'footer-top\').\'">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3>\',
\'after_title\' => \'</h3>\',
));
但我不满意