Hey so I am trying to create this conditional that auto creates a grid layout when widgets/sidebars are added and removed. The goal is let the user put in as many widgets as possible without worrying about the layout. This is my code, let me know if you want me to further explain myself:
if (function_exists('create_widget') && dynamic_sidebar('sidebar-1') && dynamic_sidebar('sidebar-2') && dynamic_sidebar('sidebar-3') ) {
$layout_classes = "col-md-4";
} elseif ( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) ) {
$layout_classes = "col-md-6";
} else {
$layout_classes = "col-md-2";
}
<div class="row"
<div class="container">
<div class="col-md-12">
<div class="<?php echo $layout_classes ?>">
<?php dynamic_sidebar( 'sidebar-1'); ?>
<?php dynamic_sidebar( 'sidebar-2'); ?>
<?php dynamic_sidebar( 'sidebar-3'); ?>
</div>
</div>
</div>
</div><!--End Layout Class-->
P.S. Using Bootstrap 3.