• Resolved alarias

    (@alarias)


    Hello,

    I want to add a sidebar to woocommerce category page, so i need to make a widgetized area on the page template.

    i added the following code to my child theme’s functions.php (i use Divi as main theme):

    if ( function_exists('register_sidebar') )
      register_sidebar(array(
        'name' => 'kategoriwidget',
        'before_widget' => '<div class = "kategoriwidget">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
      )
    );

    also i added the following code to woocommerce archive-product.php page:

    <?php if ( !function_exists('dynamic_sidebar') ||
     !dynamic_sidebar('kategoriwidget') ) : ?>
    <?php endif; ?>

    But it does not work on my site, am i missing something here?
    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • All you need is this:

    <?php if(!dynamic_sidebar('kategoriwidget')) ; ?>

    You then need to add widgets to it for it to display them in the widget area.

    If you switch themes ever, you would lose the functions file also…

    Oh! and you need to define the function in the functions file.

    And, after even further review, we need more in the array:

    In functions.php:

    function my_widget_init() {
    register_sidebar(array(
       'name' => 'Kategori Widget',
       'id' => 'kategoriwidget',
       'description' => 'Kategori Widget',
       'before_widget' => '<div class="kategoriwidget">',
       'after_widget' => '</div>',
       'before_title' => '<h3>',
       'after_title' => '</h3>',
     )
    );
    }
    add_action( 'widgets_init', 'my_widget_init' );

    In your template:
    <?php if(!dynamic_sidebar('kategoriwidget')) ; ?>

    Hope that helps!

    Thread Starter alarias

    (@alarias)

    @swansonphotos It worked! Thank you very much for your help ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add custom widget area to woocommerce ccategory page?’ is closed to new replies.