Slider on Shop and archive pages

You can display WCPS on shop an archive page,

on shop page: you can use the following code under theme functions.php file to display slider on shop page before loop.

add_action( 'woocommerce_before_shop_loop', 'wcps_on_shop_page_top', 20 );

function wcps_on_shop_page_top($content) {
    $active_plugins = get_option('active_plugins');
    $shop_page_id = wc_get_page_id('shop');
    if(in_array( 'woocommerce/woocommerce.php', (array) $active_plugins ) && is_woocommerce() && is_shop()){

        ?>
        <?php echo do_shortcode("[wcps id='1840']"); ?>
        <?php

    }
}

See the screenshot

View post on imgur.com

on all archive page including shop page

add_action( 'woocommerce_before_shop_loop', 'wcps_on_shop_page_top', 20 );

function wcps_on_shop_page_top($content) {
    $active_plugins = get_option('active_plugins');
    $shop_page_id = wc_get_page_id('shop');
    if(in_array( 'woocommerce/woocommerce.php', (array) $active_plugins ) && is_woocommerce()){

        ?>
        <?php echo do_shortcode("[wcps id='1840']"); ?>
        <?php

    }
}

Exclude shop page

add_action( 'woocommerce_before_shop_loop', 'wcps_on_shop_page_top', 20 );

function wcps_on_shop_page_top($content) {
    $active_plugins = get_option('active_plugins');
    $shop_page_id = wc_get_page_id('shop');
    if(in_array( 'woocommerce/woocommerce.php', (array) $active_plugins ) && is_woocommerce() && !is_shop()){

        ?>
        <?php echo do_shortcode("[wcps id='1840']"); ?>
        <?php

    }
}

 


Warning: Trying to access array offset on value of type bool in /home/u168435575/domains/pickplugins.com/public_html/wp-content/plugins/post-grid/includes/blocks/functions-blocks.php on line 1174