How to create widget in wordpress ?



Add below code in you functions.php file

function homesection1() {
 register_sidebar( array(
  'name'          => __( 'Home Section 1', 'shops' ),
  'id'            => 'homesection1',
  'description'   => __( 'Add widgets here to appear in your sidebar.', 'shops' ),
  'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  'after_widget'  => '</aside>',
  'before_title'  => '<h2 class="widget-title">',
  'after_title'   => '</h2>',
 ) );
}
add_action( 'widgets_init', 'homesection1' );


Print sidebar in page 

<?php 
if ( is_active_sidebar( 'homesection1' ) ) :
 dynamic_sidebar( 'homesection1' );
endif;
?> 



Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.