jcadima
5/4/2017 - 4:16 PM

Custom Header Image for Category page Woocommerce

Custom Header Image for Category page Woocommerce


https://docs.woocommerce.com/document/woocommerce-display-category-image-on-category-archive/

Select a new Image in Thumbnails and place the code below to where you want to 
show that image



<?php
	// GLOBALS
global $wp_query;
global $post;

$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
$description = wc_format_content( term_description() );
$product_cat_name = get_term_by( 'slug', 'slugname', 'product_cat' );

// GET CATEGORY NAME
$args = array( 'taxonomy' => 'product_cat',);
$terms = wp_get_post_terms($post->ID,'product_cat', $args);
// print_r($terms) ;
?>

<!--  /woocommerce/archive-product.php -->

<?php if ( $image ) : ?>
<div id="category_banner" class="white text-center" style="background:url(<?php echo $image; ?>); height: 590px; background-repeat: no-repeat;">
	
	
	<h1 class="cat_title"><?php  echo strtoupper( $terms[0]->name)  ;   ?></h1>
	<img src="<?php echo site_url(); ?>/wp-content/uploads/2017/03/linebannerleft.png">
	<div class="banner_sub"><?php echo $description;  ?></div>
	<img src="<?php echo site_url(); ?>/wp-content/uploads/2017/03/linebannerright.png">
	
	
</div>

<?php endif; ?>