0
votes

I'm having a little trouble with WordPress at the moment and was wondering if you could help out. I'm currently working on a theme and have decided to use bootstrap and added a widget area with bootstraps grid layout. I'll have 6 widgets on the page with 3 on each row. I need to count how many widgets there are and close the row div and open a new one after every 3rd widget but have no idea how to do it. I got some great help from Vladimir Ramik on here a few days ago which he helped me count the widgets like so -

<?php
    $the_sidebars = wp_get_sidebars_widgets();
    // Move count and set to var.
    $iCountWidgets = count( $the_sidebars['front-services-area'] );
    echo '<div class="row front-services">';
    for( $i = 0; $i < $iCountWidgets; ++$i )
    {
        echo $the_sidebars['front-services-area'][ $i ];
        // zero index offset.
        if ( ( $i + 1 ) % 3 == 0 ) 
        {
            // Close the row and reopen new row after every 3rd widget.
            echo '</div>';
            echo '<div class="row front-services">';
        }
    }
    echo '</div>';
?>

This does count the widgets and add the content I want but the widgets don't display the widget values (title ect.) instead it just outputs - text1 text2 search1

Any ideas?

1

1 Answers

0
votes

Why not create multiple widget areas in your template? check the link below for an example code in your functions.php http://codex.wordpress.org/Widgetizing_Themes

I think you also can solve it like this and you can easily edit it in the Wordpress admin menu.