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;

Comments

Post a Comment

Popular posts from this blog

How to add image option in nav menu in wordpress

How to change user id on checkout page for assign order to different user in woocommerce wordpress

How to add a custom sorting or order by option on category archive or product archive page in woocommerce wordpress