How to create custom sidebar in wordpress
For create custom sidebar in wordpress copy and paste below code into theme's functions.php file or into your custom plugins file.
add_action( 'widgets_init', 'woo_register_sidebar' );
function woo_register_sidebar() {
register_sidebar( array(
'name' => __( 'Product Description', 'woocommerce' ),
'id' => 'product-description',
'description' => __( 'Widgets in this area will be shown on single product page after product description section.', 'woocommerce' ),
'before_widget' => '<div class="product_description_widget">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
}
For access custom sidebar widget check below code
if ( is_active_sidebar( 'product-description' ) ) :
dynamic_sidebar( 'product-description' );
endif;
add_action( 'widgets_init', 'woo_register_sidebar' );
function woo_register_sidebar() {
register_sidebar( array(
'name' => __( 'Product Description', 'woocommerce' ),
'id' => 'product-description',
'description' => __( 'Widgets in this area will be shown on single product page after product description section.', 'woocommerce' ),
'before_widget' => '<div class="product_description_widget">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
}
For access custom sidebar widget check below code
if ( is_active_sidebar( 'product-description' ) ) :
dynamic_sidebar( 'product-description' );
endif;
Thank You for sharing this informative post. Looking forward to reading more.
ReplyDeleteBest WordPress Development services