Site logo

[Support request] Add WIDGET inside ELEMENT

Home Forums Support [Support request] Add WIDGET inside ELEMENT

Home Forums Support Add WIDGET inside ELEMENT

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2560616
    Francisco

    Hi, I need to create a ELEMENT that will be placed inside some pages (in APPAREANCE -> ELEMENTS) . Inside that ELEMENT I need to add a WIDGET. Is that possible?

    I have also tried creating this

    function woo_custom_sidebar() {
    register_sidebar(array(
    ‘name’ => ‘Widget para Buscador de Vehiculos’,
    ‘id’ => ‘wooshopwidget’,
    ‘description’ => ‘Widget para Buscador de Vehiculos’,
    ‘before_widget’ => ‘

    ‘,
    ‘after_widget’ => ‘

    ‘,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    )
    );
    }
    add_action( ‘widgets_init’, ‘woo_custom_sidebar’ );

    And then inserted this CODE inside the ELEMENT:

    <?php if(!dynamic_sidebar(‘wooshopwidget’)) ; ?>

    But it doesnt work.

    Thanks
    Francisco

    #2560719
    Ying
    Staff
    Customer Support

    Hi Francisco,

    What’s the widget you want to add?

    Does the widget have a block version? If so, you can add the block to the block element.

    Let me know!

    #2562065
    Francisco

    I have finally added like this

    function my_zone_widgets() {
        register_sidebar( array(
            'name' => __( 'My Widgets Area', 'mi-tema' ),
            'id' => 'my_widgets_area',
            'description' => __( 'Esta es mi zona de widgets personalizada', 'mi-tema' ),
            'before_widget' => '<div class="widget">',
            'after_widget' => '</div>',
            'before_title' => '<h2 class="widget-title">',
            'after_title' => '</h2>',
        ) );
    }
    add_action( 'widgets_init', 'my_zone_widgets' );
    
    add_action( 'woocommerce_archive_description', 'my_function_widget', 10 );
    function my_function_widget() {
        if ( is_shop() ) {
            echo '<div class="nueva-area-de-widgets content-area" style="width: 100% !important;text-align: center !important;padding:20px;margin-bottom: 20px;border-radius: 25px;">';
            dynamic_sidebar( 'my_widgets_area' );
            echo '</div>';
        }
    }
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.