mateusz-wodnik
12/2/2018 - 2:09 PM

Custom Widget Area

Adding Widget Ready Areas or Sidebar in WordPress Themes

<?php
// Create
add_action( 'widgets_init', function() {
  $args = [
      'id'            => 'custom_sidebar',
      'name'          => __( 'Custom Widget Area', 'text_domain' ),
      'description'   => __( 'A custom widget area', 'text_domain' ),
      'before_title'  => '<h3 class="widget-title">',
      'after_title'   => '</h3>',
      'before_widget' => '<aside id="%1$s" class="widget %2$s">',
      'after_widget'  => '</aside>',
  ];
  register_sidebar( $args );
} );
// Display
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('custom_sidebar') ) : ?>
<!–Default sidebar info goes here–>
<?php endif; ?>