Support » Plugin: YITH WooCommerce Ajax Product Filter » Only widget no shortcode or top page filter

Viewing 1 replies (of 1 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi,
    and thank you for your feedback!

    About the “top page filter”, this depends on your theme: if your theme adds a sidebar on the top of the page you’ll be able to show filters there.

    About the shortcode, you can easily achieve your goal by adding the following code snippet to your theme functions.php

    if ( ! function_exists( 'yith_customization_register_sidebars' ) ) {
        add_action( 'widgets_init', 'yith_customization_register_sidebars' );
        function yith_customization_register_sidebars(){
            register_sidebar( array(
                'name'          => 'Custom Shortcode Sidebar',
                'id'            => 'custom-shortcode-sidebar',
                'description'   => 'Use [custom_sidebar] to render this sidebar.',
                'before_widget' => '<section id="%1$s" class="custom-shortcode-sidebar__widget %2$s">',
                'after_widget'  => '</section>',
                'before_title'  => '<h2 class="custom-shortcode-sidebar__widget-title">',
                'after_title'   => '</h2>',
            ) );
        }
    
    }
    
    if ( ! function_exists( 'yith_customization_render_custom_sidebar_shortcode' ) ) {
        add_shortcode( 'custom_sidebar', 'yith_customization_render_custom_sidebar_shortcode' );
    
        function yith_customization_render_custom_sidebar_shortcode(){
            ob_start();
            dynamic_sidebar( 'custom-shortcode-sidebar' );
            return ob_get_clean();
        }
    }

    After adding this shortcode you’ll see a new sidebar, called “Custom Shortcode Sidebar“, where you can add the widgets you prefer; after setting your widgets there, you’ll be able to render the sidebar wherever you want by using the [custom_sidebar] shortcode.
    Please try this solution and let us know if this will cover your case.

    • This reply was modified 1 year, 7 months ago by YITHEMES.
Viewing 1 replies (of 1 total)
  • The topic ‘Only widget no shortcode or top page filter’ is closed to new replies.