added ability for product tag to be the header image
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 14 Jul 2016 20:53:19 +0000 (16:53 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 14 Jul 2016 20:53:19 +0000 (16:53 -0400)
functions.php

index 24e52e9..1f062bb 100644 (file)
@@ -225,18 +225,26 @@ function glm_get_header() {
     if ( $post->post_parent && !has_post_thumbnail($post->ID)){
         $post_id = $post->post_parent;
     }
-  
     echo '<div class="header-image-background"';
-    if(is_product() || is_page(101) || is_product_tag() ){
+    if(is_product() || is_page(101) ){
+            
             $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(101), "full");
             echo ' style="background-image: url('.$image_data[0].');padding:0;padding-bottom:20%;background-position:center center;background-size: cover;background-repeat:no-repeat;max-height: 370px "';
     } else if ( is_product_category() ){
             $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(100), "full");
             echo ' style="background-image: url('.$image_data[0].');padding:0;padding-bottom:20%;background-position:center center;background-size: contain;background-repeat:no-repeat;max-height: 370px; "';
-    }
-    else if ( has_post_thumbnail($post_id) && is_post_type('page')) {
+    } else if ( has_post_thumbnail($post_id) && is_post_type('page')) {
             $image_data = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), "full");
             echo ' style="background-image: url('.$image_data[0].');padding:0;padding-bottom:20%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 370px; "';
+    } else if ( is_product_tag() ){
+        
+            $tag = get_queried_object();
+            $tagID = $tag->term_id;
+        
+            $thumbnail = z_taxonomy_image_url( (int)$object->object_id );
+        
+            echo ' style="background-image: url('.$thumbnail.');padding:0;padding-bottom:20%;background-position:center center;background-size: cover;background-repeat:no-repeat;max-height: 370px; "';
+            
     } else {
             echo ' style="background-image: url('.get_template_directory_uri().'/assets/header-images-2.jpg);padding:0;padding-bottom:30%;background-position:center center;background-size:cover;background-repeat:no-repeat;max-height: 370px; "';
             echo ' class="no-featured"';