-
AuthorPosts
-
January 30, 2015 at 3:06 am #388092
Hi! Thank you for the theme! we were wondering if we could have a custom header for each woocommerce product category? We were able to add a header via custom header plugin here: https://aquaquestonline.com/product-category/backpacks/ but we really wanted it to be starting from the very top of the page like in Geode demo.
Thanks,
Gear Out Here- This topic was modified 9 years, 10 months ago by Andy.
January 31, 2015 at 12:50 am #388649Hi gearouthere!
did you try one of these plugins?
https://wordpress.org/plugins/custom-header-extended/
https://wordpress.org/plugins/custom-header-images/Best regards,
AndyFebruary 2, 2015 at 7:48 pm #389599Hi Andy, thanks for your reply! Those are both for adding header to post (not woocommerce product category) and the first one doesn’t work with WordPress 4.1 .. I was wondering if there was a solution we could implement through the theme to enable a header on the woo-commerce product category page?…
February 4, 2015 at 12:11 pm #390676Hi!
You can put something like this on functions.php:
function ava_product_category_banner() { if(has_term('artifact', 'product_cat')) { echo "<div class='product_category_banner container_wrap'>ARTIFACT IMAGE HERE</div>"; } else if(has_term('treasure', 'product_cat')) { echo "<div class='product_category_banner container_wrap'>TREASURE IMAGE HERE</div>"; } }
Add the link to the image then change the product category. Below, add this:
add_action('wp_footer', 'ava_product_category', 5); function ava_product_category(){ ?> <script> (function($){ $(window).load(function() { $('.product_category_banner').css('opacity', 1); $('.product_category_banner').prependTo('.container_wrap.template-shop'); }); })(jQuery); </script> <?php }
Go to Enfold > General Styling > Quick CSS field, add this:
.product_category_banner { opacity: 0;; height: 100px; border-bottom: 1px solid gray; background: red; }
You’ll have a fullwidth container on top of the product category page. All you need to do is to adjust the styling and add the images.
Regards,
IsmaelFebruary 4, 2015 at 8:08 pm #390889Hi Ismael, thank you so much for your help!! . I added the code but it didn’t seem to change anything. (I added to functions.php the following:
/* adding header for category pages*/
function ava_product_category_banner() {
if(has_term(‘Backpacks’, ‘product_cat’)) {
echo “<div class=’product_category_banner container_wrap’>http://aquaquestonline.com/wp-content/uploads/2014/04/kayakbetter.jpg</div>”;
}
else if(has_term(‘Tarps’, ‘product_cat’)) {
echo “<div class=’product_category_banner container_wrap’>http://aquaquestonline.com/wp-content/uploads/2014/04/kayakbetter.jpg</div>”;
}
}add_action(‘wp_footer’, ‘ava_product_category’, 5);
function ava_product_category(){
?>
<script>
(function($){
$(window).load(function() {
$(‘.product_category_banner’).css(‘opacity’, 1);
$(‘.product_category_banner’).prependTo(‘.container_wrap.template-shop’);
});
})(jQuery);
</script>
<?php
}I added the CSS you advised as well.. Maybe I am doing something wrong?
Thanks so much,
Gear Out Here
February 6, 2015 at 10:59 am #391902Hi!
Instead of the term name, please use the term id.
function ava_product_category_banner() { if(has_term('26', 'product_cat')) { echo "<div class='product_category_banner container_wrap'><img src="http://aquaquestonline.com/wp-content/uploads/2014/04/kayakbetter.jpg"></div>"; } else if(has_term('46', 'product_cat')) { echo "<div class='product_category_banner container_wrap'><img src="http://aquaquestonline.com/wp-content/uploads/2014/04/kayakbetter.jpg"></div>"; } }
Adjust the ids above.
Regards,
IsmaelFebruary 6, 2015 at 8:44 pm #392259Hi Ismael,
thanks so much for looking into this. It actually still breaks the site and gives the following error: Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /nfs/c09/h04/mnt/188733/domains/aquaquestonline.com/html/wp-content/themes/enfold/functions.php on line 1088
I have a feeling there’s maybe one sign missed but I don’t have enough php knowledge to fix it..Thank you,
Gear Out HereFebruary 8, 2015 at 6:38 am #392636Hey!
Try the following instead please:
function ava_product_category_banner() { if(has_term('26', 'product_cat')) { echo '<div class="product_category_banner container_wrap"><img src="http://aquaquestonline.com/wp-content/uploads/2014/04/kayakbetter.jpg"></div>'; } else if(has_term('46', 'product_cat')) { echo '<div class="product_category_banner container_wrap"><img src="http://aquaquestonline.com/wp-content/uploads/2014/04/kayakbetter.jpg"></div>'; } }
Best regards,
RikardApril 14, 2015 at 2:40 pm #428237Hi Guys..
Actually we can add Image banners to product categories and archives by using the Theme Designer
A very similar Problem to this above.I want to display the same long imagebanner from the category pages also on my singe products.
I do the following:
function add_banner_before_breadcrumb() { if ( is_product() ) { echo '<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-st…verlay-active avia-bg-style-parallax container_wrap fullsize" style="color:#ffffff;" data-section-bg-repeat="stretch"> <div class="av-parallax avia-full-stretch" style="background-image: url("http://sst.seite-freigeben.de/wp-content/uploads/stripe_Poducts11.jpg")"; ></div> </div>'; } } add_action('ava_after_main_container', 'add_banner_before_breadcrumb');
But the javascript is a bit buggy after using this. Can you help me?
htaccess:
user: SST
login: Somer2015!April 16, 2015 at 8:58 am #429413Hey!
You can try this:
add_action('ava_after_main_container', 'add_banner_before_breadcrumb'); function add_banner_before_breadcrumb() { if ( is_product() ) { echo '<div id="av_product_description" class="avia-section main_color avia-section-default avia-no-shadow avia-full-stretch av-parallax-section avia-bg-style-parallax av-minimum-height av-minimum-height-75 container_wrap fullsize" style="color:#ffffff;" data-section-bg-repeat="stretch"> <div class="av-parallax avia-full-stretch"></div> </div>'; } } add_action('wp_footer', 'ava_custom_script_parallax'); function ava_custom_script_parallax(){ ?> <script> (function($){ $('#av_product_description .av-parallax').css('background-image', 'url(' + 'http://sst.seite-freigeben.de/wp-content/uploads/stripe_Poducts11.jpg' + ')'); $('#av_product_description').css('height', '500px'); })(jQuery); </script> <?php }
Set the height of the #av_product_description manually.
Regards,
IsmaelJuly 19, 2016 at 8:44 am #662358Hello,
when I insert the code above in my functions.php + the CSS code changes, unfortunately, nothing. The term ids I have changed. Can I do it so translated that the products per category get all the same headers? Many thanks for your help!
July 19, 2016 at 6:27 pm #662666Hi @envato1901,
Please open a new thread and post admin login details in private so that we can have a closer look. Also try to explain your problem a bit closer so that we get an understanding of what you are looking to achieve.
Regards,
Rikard -
AuthorPosts
- You must be logged in to reply to this topic.