Tagged: banner, category page, enfold, shop, woocommerce
-
AuthorPosts
-
November 9, 2017 at 3:59 pm #874732
Hi, I found the following piece of code on a related thread. It fixes the issue described in the previous thread for category pages, but at the same time it seems to remove the banner image for the main shop page. How could this code be adjusted to not remove the banner image (set in Enfold > Shop) on the main shop page?
// Fix Enfold from using 1500px wide image and use the full-size image instead add_action( 'init', 'ssi_woocommerce_full_width_category_images', 50 ); function ssi_woocommerce_full_width_category_images() { remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 ); add_action( 'ava_after_main_container', 'avia_woocommerce_parallax_banner_child_theme', 11); function avia_woocommerce_parallax_banner_child_theme($bg, $overlay, $opacity, $description, $font) { if(is_numeric($bg)) { $bg = wp_get_attachment_image_src($bg, 'full'); if(is_array($bg) && $bg[0] != "") $bg = $bg[0]; } if($font) $font = "style='color:{$font};'"; if($bg) $bg = "background-image: url(".$bg.");"; $output = ""; $output .='<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-styling avia-full-stretch av-parallax-section av-section-color-overlay-active avia-bg-style-parallax container_wrap fullsize" data-section-bg-repeat="stretch" '.$font.'>'; $output .='<div class="av-parallax avia-full-stretch" data-avia-parallax-ratio="0.3">'; $output .='<div class="av-parallax-inner" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">'; $output .='</div>'; $output .='</div>'; $output .='<div class="av-section-color-overlay-wrap">'; if(!empty($overlay)) { $output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>'; } $output .='<div class="container">'; $output .='<main class="template-page content av-content-full alpha units">'; if($description) $output .= "<h1>".$description."</h1>"; $output .='</main></div></div></div>'; return $output; } remove_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 ); add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner_child_theme', 11 ); function avia_woocommerce_big_cat_banner_child_theme() { if(is_product_category()) { global $wp_query, $avia_config; if(isset($wp_query->query_vars['taxonomy'])) { $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']); if(!empty($term->term_id)) { $description = term_description() ; $style = get_woocommerce_term_meta($term->term_id, 'av_cat_styling'); $attachment_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id'); $overlay = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay'); $font = get_woocommerce_term_meta($term->term_id, 'av-banner-font'); $opacity = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity'); if(!empty($style)) { remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 ); echo avia_woocommerce_parallax_banner_child_theme($attachment_id, $overlay, $opacity, $description, $font); $avia_config['woo-banner'] = true; } } } } } }
November 13, 2017 at 4:00 am #875916Hey Andrius,
Thank you for using Enfold.
How could this code be adjusted to not remove the banner image (set in Enfold > Shop) on the main shop page?
Please remove the following line.
remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
Best regards,
IsmaelNovember 14, 2017 at 1:54 pm #876563Hi @Ismael,
thanks for your reply. However, removing the line seems to duplicate the banners. On the main shop page I get a single shop banner (set in Enfold > Shop), but in the category pages I get both – the main shop banner as well as the category banner. I’d like to have the main banner (Enfold > Shop) only displayed on the main shop page and on category pages I’d like to see only the category-specific banner.- This reply was modified 7 years, 1 month ago by Andrius.
November 15, 2017 at 7:32 pm #877195Hi @Ismael, I was just wondering if you have any updates on my message above?
November 16, 2017 at 4:34 am #877348Hi,
I’m sorry for the late response. Please replace it with the following code instead.
if( is_tax( 'product_cat' ) && ! is_shop() ) { remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 ); }
Best regards,
IsmaelNovember 16, 2017 at 12:35 pm #877483Hi @ismael, many thanks for your response. However, the issue persists. The banners are still doubled on the category page.
Here’s the full code I’m using:
// Fix Enfold from using 1500px wide image and use the full-size image instead add_action( 'init', 'ssi_woocommerce_full_width_category_images', 50 ); function ssi_woocommerce_full_width_category_images() { if( is_tax( 'product_cat' ) && ! is_shop() ) { remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 ); } add_action( 'ava_after_main_container', 'avia_woocommerce_parallax_banner_child_theme', 11); function avia_woocommerce_parallax_banner_child_theme($bg, $overlay, $opacity, $description, $font) { if(is_numeric($bg)) { $bg = wp_get_attachment_image_src($bg, 'full'); if(is_array($bg) && $bg[0] != "") $bg = $bg[0]; } if($font) $font = "style='color:{$font};'"; if($bg) $bg = "background-image: url(".$bg.");"; $output = ""; $output .='<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-styling avia-full-stretch av-parallax-section av-section-color-overlay-active avia-bg-style-parallax container_wrap fullsize" data-section-bg-repeat="stretch" '.$font.'>'; $output .='<div class="av-parallax avia-full-stretch" data-avia-parallax-ratio="0.3">'; $output .='<div class="av-parallax-inner" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">'; $output .='</div>'; $output .='</div>'; $output .='<div class="av-section-color-overlay-wrap">'; if(!empty($overlay)) { $output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>'; } $output .='<div class="container">'; $output .='<main class="template-page content av-content-full alpha units">'; if($description) $output .= "<h1>".$description."</h1>"; $output .='</main></div></div></div>'; return $output; } remove_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 ); add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner_child_theme', 11 ); function avia_woocommerce_big_cat_banner_child_theme() { if(is_product_category()) { global $wp_query, $avia_config; if(isset($wp_query->query_vars['taxonomy'])) { $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']); if(!empty($term->term_id)) { $description = term_description() ; $style = get_woocommerce_term_meta($term->term_id, 'av_cat_styling'); $attachment_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id'); $overlay = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay'); $font = get_woocommerce_term_meta($term->term_id, 'av-banner-font'); $opacity = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity'); if(!empty($style)) { remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 ); echo avia_woocommerce_parallax_banner_child_theme($attachment_id, $overlay, $opacity, $description, $font); $avia_config['woo-banner'] = true; } } } } } }
November 17, 2017 at 6:26 am #877949Hi,
Thank you for the update.
Please try this instead.
if( is_tax( 'product_cat' ) ) { remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 ); }
If it’s still not working, please post the WP and FTP details in the private field so that we can test it.
Best regards,
IsmaelNovember 17, 2017 at 5:52 pm #878218Hi @ismael, I’ve added your adjusted code and it completely stopped the website from rendering (no error, but renders a blank white page). Could you please log in to the site and have a look? I have commented out the code snippet so the site loads now.
November 18, 2017 at 10:30 am #878452Hi mazeika!
Can you please check server log for error?
Cheers!
VictoriaNovember 21, 2017 at 9:12 pm #879929Hi @victoria, which server log should I check and for what kind of error? the problem is clearly in the code snippet provided by @ismael as the site works once it’s commented out and worked with previous versions of his snippet. However, I really need to be able change the category page banners per category yet keep the main shop banner (set in Enfold > Shop). I provided the admin logins in the post below.
November 24, 2017 at 4:43 am #881005Hi,
Did you set the “e-parduotuve/” page as the base shop page in the Woocommerce > Settings > Products panel?
Best regards,
IsmaelNovember 24, 2017 at 6:01 am #881063@ismael, yes, that’s correct
November 26, 2017 at 12:24 am #881804 -
AuthorPosts
- You must be logged in to reply to this topic.