Created
March 24, 2014 23:00
-
-
Save ewels/9751176 to your computer and use it in GitHub Desktop.
Example theme code for Bootstrap Feature Widgets plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Outputting the widget area on your homepage | |
| // Accomodates one to four active widget areas, fits bootstrap columns accordingly | |
| // front-page.php | |
| $widget_count = 0; | |
| for ($i = 1; $i <= 4; $i++){ | |
| if ( is_active_sidebar('homepage-widget-area-'.$i) ) $widget_count++; | |
| } | |
| if ( $widget_count > 0) { | |
| $widget_column_class = floor(12 / $widget_count); | |
| echo '<div class="row homepage-widgets">'; | |
| for ($i = 1; $i <= 4; $i++){ | |
| echo '<div class="col-md-'.$widget_column_class.'">'; | |
| if ( is_active_sidebar('homepage-widget-area-'.$i) ) { | |
| dynamic_sidebar( 'homepage-widget-area-'.$i ); | |
| } | |
| echo '</div>'; | |
| } | |
| echo '</div>'; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Activating Four Widget areas in your theme | |
| // functions.php | |
| function mysite_widgets_init() { | |
| for($i = 1; $i <= 4; $i++){ | |
| register_sidebar( array( | |
| 'name' => "Homepage - $i", | |
| 'id' => "homepage-widget-area-$i", | |
| 'description' => "Widget area number $i on the homepage.", | |
| 'before_widget' => '', | |
| 'after_widget' => '', | |
| 'before_title' => '<h2 class="widget-title">', | |
| 'after_title' => '</h2>', | |
| ) ); | |
| } | |
| } | |
| add_action( 'widgets_init', 'mysite_widgets_init' ); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Some style tweaks to make everything look as you'd like */ | |
| /* style.css */ | |
| .homepage-widgets .glyphicon { | |
| font-size:100px; | |
| color:#D6A200; | |
| } | |
| .homepage-widgets .bootstrap-feature-widget-news { | |
| padding:0; | |
| list-style-type: none; | |
| } | |
| .homepage-widgets .bootstrap-feature-widget-news li:before{ | |
| content: "\00BB"; | |
| margin-right:10px; | |
| } | |
| .homepage-widgets .bootstrap-feature-widget-news a { | |
| color:#333; | |
| } | |
| .homepage-widgets .bootstrap-feature-widget-news a:hover { | |
| color:#2a6496; | |
| text-decoration:none; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment