Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey Peiler, I had the same issue myself. Maybe I can help.

    I found that WCB isn’t working with Salient because of how Salient calls woocommerce content inside of the file woocommerce.php.

    WCB passes their class to the action hook woocommerce_before_main_content, but since there’s no do_action(‘woocommerce_before_main_content’) hook in Salient’s woocommerce.php file, it doesn’t show up.

    You could do a few things, either add the hook do_action(‘woocommerce_before_main_content’); to the file, and have the banner image loaded inside of div.main-content, or you can add this hook do_action(‘before_woocommerce_init’); and have it load before the main content and be a fullwidth banner image.

    Below is what I changed to get WCB working with a child theme of Salient.

    Open your functions.php file and add this line:
    add_action( 'before_woocommerce_init', array( 'WCB_Category_Banner', 'wcb_show_category_banner' ), 30 );

    now open your woocommerce.php file and change this block:

    <?php get_header();
    
    if(is_shop() || is_product_category() || is_product_tag()) {
    
    	//page header for main shop page
    	nectar_page_header(woocommerce_get_page_id('shop'));
    
    }

    to this:

    <?php get_header();
    
    if( is_shop() ) {
    	//page header for main shop page
    	nectar_page_header(woocommerce_get_page_id('shop'));
    
    } else {
    	if ( is_product_category() || is_product_tag() ) {
    ?>
    		<div class="banner">
    			<?php do_action( 'before_woocommerce_init' ); ?>
    		</div>
    
    <?php
    	}
    }

    I also had to include the styling below so there wasn’t a gap at the bottom of the banner image.

    .woocommerce img, .woocommerce-page img {
    	vertical-align: middle;
    }

    Cheers

    Hi, im using a Yith theme, and i want to add the banner on top of all so i have a fulld with banner.

    I replace the main_conten hook for “before_woocommerce_init” using wordpress editor but it doesnt show anything now.

    I search for the code you put of the php get_header, but i couldnt find it in woocommerce.php

    Thr functions.php file is the main functions.php file of wordpress?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Not working Banner’ is closed to new replies.