Categories
Ignis

Add Footer Widgets Area to Ignis Theme

Add this simple PHP snippet to a child theme’s functions. You’ll have a new “Footer Widgets Area” sidebar box in your site’s Appearance > Widgets panel.

/** 
 * Register new sidebar area.
 */
function ignis_child_widgets_init() {
  register_sidebar( array(
    'name'          => esc_html__( 'Footer Widgets Area', 'ignis' ),
    'id'            => 'footer-widgets-area',
    'description'   => esc_html__( 'All widgets here will be displayed on footer area.', 'ignis' ),
    'before_widget' => '<section id="%1$s" class="widget %2$s">',
    'after_widget'  => '</section>',
    'before_title'  => '<h4 class="widget-title">',
    'after_title'   => '</h4>',
  ) );
}
add_action( 'widgets_init', 'ignis_child_widgets_init' );

/** 
 * Display new sidebar area on theme's footer with ignis_footer hook.
 */
add_action('ignis_footer', 'ignis_child_add_footer_widget_widgets', 5);
function ignis_child_add_footer_widget_widgets() {

  if ( ! is_active_sidebar( 'footer-widgets-area' ) ) {
  	return;
  }
  ?>
  <aside id="footer-widgets-area" class="footer-widget-area" role="complementary">
  	<?php dynamic_sidebar( 'footer-widgets-area' ); ?>
  </aside><!-- #secondary -->
  <?php 
	  
}

Leave a Reply

Your email address will not be published. Required fields are marked *