Sela added widget area alignment issue
-
I added a widget area below the hero area prior to the first original widget area. To do this, I added the following to a cloned functions.php file in my child theme to initialize three new widget areas:
function arphabet_widgets_init() {
register_sidebar( array( 'name' => 'Frontpage sub-hero area 1', 'id' => 'front_sub_hero1', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) ); register_sidebar( array( 'name' => 'Frontpage sub-hero area 2', 'id' => 'front_sub_hero2', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) ); register_sidebar( array( 'name' => 'Frontpage sub-hero area 3', 'id' => 'front_sub_hero3', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'arphabet_widgets_init' ); ?>
I then cloned the front-page.php to my child theme and added code that activated these three areas between the original primary and secondary areas:
<div id="primary-sidebar" class="widget-area front-widget-area" role="complementary"> <?php dynamic_sidebar( 'front_sub_hero1' ); ?> <?php dynamic_sidebar( 'front_sub_hero2' ); ?> <?php dynamic_sidebar( 'front_sub_hero3' ); ?> </div><!-- #primary-sidebar -->
I added a text widget to each of these new sub-hero areas to see what would happen and the widget areas are working and appearing. However, the problem is that they are in a running fashion vertically.
I then added a second text widget to the first added widget area, and the widgets are running vertically within the individual widget areas also. I need to get the widgets to run horizontally across the page somehow. Either by getting one of the widget areas to display its widgets horizontally, or by getting the three new widgets areas themselves to align horizontally (just as the theme frontpage widget columns align horizontally).
I looked at the CSS for the original widget columns to see how they get aligned horizontally and found this (which I think is related) in the parent theme style.css:
/* Front Page & Footer Widget Areas */ .footer-widget-area .widget-area { margin: 0; } .front-widget-area .widget-area, .footer-widget-area .widget-area { float: left; } .front-widget-area .widget-area:nth-child(1):nth-last-child(1), .footer-widget-area .widget-area:nth-child(1):nth-last-child(1) { width: 100%; } .front-widget-area .widget-area:nth-child(1):nth-last-child(2), .front-widget-area .widget-area:nth-child(2):nth-last-child(1), .footer-widget-area .widget-area:nth-child(1):nth-last-child(2), .footer-widget-area .widget-area:nth-child(2):nth-last-child(1) { margin-right: 6%; width: 47%; } .front-widget-area .widget-area:nth-child(1):nth-last-child(2):last-of-type, .front-widget-area .widget-area:nth-child(2):nth-last-child(1):last-of-type, .footer-widget-area .widget-area:nth-child(1):nth-last-child(2):last-of-type, .footer-widget-area .widget-area:nth-child(2):nth-last-child(1):last-of-type { margin-right: 0; } .front-widget-area .widget-area:nth-child(1):nth-last-child(3), .front-widget-area .widget-area:nth-child(2):nth-last-child(2), .front-widget-area .widget-area:nth-child(3):nth-last-child(1), .footer-widget-area .widget-area:nth-child(1):nth-last-child(3), .footer-widget-area .widget-area:nth-child(2):nth-last-child(2), .footer-widget-area .widget-area:nth-child(3):nth-last-child(1) { margin-right: 5%; width: 30%; } .front-widget-area .widget-area:nth-child(1):nth-last-child(3):last-of-type, .front-widget-area .widget-area:nth-child(2):nth-last-child(2):last-of-type, .front-widget-area .widget-area:nth-child(3):nth-last-child(1):last-of-type, .footer-widget-area .widget-area:nth-child(1):nth-last-child(3):last-of-type, .footer-widget-area .widget-area:nth-child(2):nth-last-child(2):last-of-type, .footer-widget-area .widget-area:nth-child(3):nth-last-child(1):last-of-type { margin-right: 0; } }
Can I somehow apply this to the widget areas I have added to get them to display horizontally?
- The topic ‘Sela added widget area alignment issue’ is closed to new replies.