how do i add custom widget woocommerce shop page with php

Question

I want to create a widget that will only appear on the shop page, but I couldn’t get any results.

functions.php

function kucuksun_widgets_init() {
    register_sidebar(
        array(
            'name'          => esc_html__( 'Sidebar', 'kucuksun' ),
            'id'            => 'sidebar-1',
            'description'   => esc_html__( 'Add widgets here.', 'kucuksun' ),
            'before_widget' => '<section id="%1$s" class="widget %2$s">',
            'after_widget'  => '</section>',
            'before_title'  => '<h2 class="widget-title">',
            'after_title'   => '</h2>',
        ),
        register_sidebar(
        array(
            'name'          => esc_html__( 'Shop', 'kucuksun' ),
            'id'            => 'shop',
            'description'   => esc_html__( 'Add widgets here.', 'kucuksun' ),
            'before_widget' => '<section id="%1$s" class="widget %2$s">',
            'after_widget'  => '</section>',
            'before_title'  => '<h2 class="widget-title">',
            'after_title'   => '</h2>',
        )
       )
    );
}
add_action( 'widgets_init', 'kucuksun_widgets_init' );

Following my code: sidebar.php

<?php

if ( ! is_active_sidebar( 'sidebar-1' ) ) {
    return;
}
?>

<aside id="secondary" class="widget-area">
    <?php dynamic_sidebar( 'sidebar-1' ); ?>
</aside>

I’m not exactly sure but I need to print it in
woocommerce.php dynamic_sidebar( 'shop' );

0
Ferhat 4 weeks 2021-09-24T01:35:38-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse