Advertisement
numediaweb

wpquestions.3140 v4

Oct 13th, 2011
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.85 KB | None | 0 0
  1. <?php
  2.  
  3. get_header();
  4.  
  5. $taxonomy_single = get_query_var( 'term' ) ;
  6.  
  7. ?>     
  8.  
  9.  
  10. <div id="omc-header-under">
  11.        
  12. <span id="omc-header-overlay"></span>
  13.  
  14. <?php
  15.  
  16.  
  17.     $theme_options = get_option('option_tree');
  18.     $header_image_upload =  get_option_tree( 'header_image_upload', $theme_options, false );
  19.     $header_image_select =  get_option_tree( 'header_image_select', $theme_options, false );
  20.     $blog_header =  get_option_tree( 'blog_page_header', $theme_options, false );
  21.     $products_upload =  get_option_tree( 'products_upload', $theme_options, false );
  22.     $skin =  get_option_tree( 'skin', $theme_options, false );
  23. if ($products_upload !='') { ?>
  24.  
  25.     <img  width="1020" src="<?php echo($products_upload);?>" alt="header image" class="omc-header-image fix-height" />     
  26. <?php } elseif ($header_image_upload !='') { ?>
  27.  
  28.     <img  width="1020" src="<?php echo($header_image_upload);?>" alt="header image" class="omc-header-image  fix-height" />    
  29. <?php } elseif ($header_image_select !='') { ?>
  30.  
  31.     <img src="<?php echo(get_template_directory_uri());?>/images/headers/<?php echo($header_image_select);?>.jpg" alt="header image" class="omc-header-image  fix-height" />       
  32. <?php } else {?>
  33.  
  34. <img height="200" width="1020" src="<?php echo(get_template_directory_uri());?>/images/skins/<?php echo($skin);?>/default_header.jpg" alt="header image" class="omc-header-image" />
  35.  
  36. <?php } ?>
  37.                
  38. <div id="omc-ribbon">
  39.  
  40.     <h1><span class="omc-ribbon-left"></span><span class="omc-ribbon-middle"><?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?></span><span  class="omc-ribbon-right"></span></h1>
  41.     <div id="omc-breadcrumb">
  42.  
  43.  
  44.         <?php  if(function_exists('bcn_display')) { bcn_display();}?>
  45.        
  46.     </div><!-- /omc-breadcrumb -->
  47.  
  48. </div>
  49.                    
  50.  
  51. </div><!-- /omc-header-under -->   
  52.  
  53.  
  54. <div class="omc-inner-page-content-wrapper right-sidebar">
  55.  
  56.  
  57. <?php if ( is_active_sidebar( 8 ) ) { ?>
  58.  
  59.     <div id="omc-sidebar" class="omc-right">
  60.        
  61.         <ul class="xoxo">
  62.        
  63.             <?php dynamic_sidebar( 'Products Sidebar' ); ?>
  64.         </ul>
  65.        
  66.     </div>
  67.  
  68. <?php } else {  get_sidebar(); } ?>
  69.  
  70. <div id="omc-main-left-column" class="omc-content">  
  71.     <span class="product-margin"></span>
  72.     <?php      
  73.         wp_reset_query();
  74.        
  75.         //var_dump( $terms );
  76.        
  77.         $defaults = array(
  78.             'product_cats' => ''
  79.         );
  80.         $args = wp_parse_args( $query_string, $defaults );
  81.         $current_cat = get_term_by('slug', $args['product_cats'], 'product_cats');
  82.        
  83.         // Gets every "category" (term) in the current taxonomy to get the respective posts
  84.         $terms = get_terms( 'product_cats', 'child_of='.$current_cat->term_id );       
  85.         $count = count($terms);
  86.        
  87.         // if the term has no children then show its content
  88.         if ( $count == 0 ):
  89.             $posts = new WP_Query( "taxonomy=product_cats&term=$current_cat->slug" );          
  90.            
  91.          ?>
  92.             <div class"clear"></div>
  93.             <br class="clear">
  94.            
  95.             <h2 style="border-bottom:1px solid #CCC;margin-top:0px;"><?php echo $current_cat->name; ?></h2>
  96.          
  97.             <?php
  98.             $i = 0;
  99.             $style = '';
  100.             if( $posts->have_posts() ) :
  101.                 while( $posts->have_posts() ) : $posts->the_post();
  102.                
  103.                     $i++;
  104.                     // fixes the margin of each 3rd product in the loop (instead of using jQuery)
  105.                     if (($i % 3) == 0) $style = ' style="margin-right: 0px;" '; else $style = '';
  106.                    
  107.                     $price =  get_post_meta(get_the_ID(), 'inception_price', true);
  108.             ?>
  109.                 <div class="omc-product-listing" <?php echo $style; ?>>
  110.                     <a href="<?php the_permalink();?>">
  111.                        
  112.                         <?php
  113.                             if(has_post_thumbnail()) {
  114.                             the_post_thumbnail('product', array('class' => 'omc-product-frame'));  
  115.                             } else {
  116.                         ?>
  117.                        
  118.                         <img src="<?php echo get_template_directory_uri() ;?>/images/no-image.png" width="170" height="170" class="omc-product-frame" alt="no photo" />
  119.                        
  120.                         <?php } ?>
  121.                        
  122.                     </a>
  123.                
  124.                     <span class="omc-listing-header"><a href="<?php the_permalink();?>"><?php the_title();?></a></span>
  125.                     <span class="omc-listing-price"><?php echo($price);?></span>
  126.                     <span class="omc-listing-more"><a href="<?php the_permalink();?>">&raquo;</a></span>
  127.                 </div><!-- /omc-product-listing -->
  128.             <?php
  129.            
  130.                 endwhile;
  131.             else:
  132.            
  133.                 echo 'no results';
  134.            
  135.             endif; wp_reset_query();
  136.        
  137.         // if the term has children then loop through them
  138.         else:
  139.    
  140.             // fix the H3 issue
  141.             $father_is_here = false;
  142.            
  143.             foreach( $terms as $term ) :
  144.            
  145.                 // if this term has child term, then ignore it
  146.                 $child_terms = get_terms( 'product_cats', 'child_of='.$term->term_id );    
  147.                 $count_children = count($child_terms);
  148.                 //var_dump( $term->name );
  149.                
  150.                 if ( $count_children > 0 ):    
  151.                
  152.                     $father_is_here = true;
  153.                 ?>
  154.                     <div class"clear"></div>
  155.                     <br class="clear">
  156.                    
  157.                     <h2 style="border-bottom:1px solid #CCC;margin-top:0px;"><?php echo $term->name; ?></h2>
  158.                  
  159.                     <?php
  160.                     continue;
  161.                 endif;
  162.                
  163.                 //query_posts($query_string . '&posts_per_page=9&paged=' . $paged);
  164.                 $posts = new WP_Query( "taxonomy=product_cats&term=$term->slug" );         
  165.                
  166.              ?>
  167.                 <div class"clear"></div>
  168.                 <br class="clear">
  169.                 <?php if ( $father_is_here ):?>
  170.                
  171.                 <h3><?php echo $term->name; ?></h3>
  172.                
  173.                 <?php else :?>
  174.                
  175.                 <h2 style="border-bottom:1px solid #CCC;margin-top:0px;"><?php echo $term->name; ?></h2>
  176.                
  177.                 <?php endif;?>
  178.              
  179.                 <?php
  180.                 $i = 0;
  181.                 $style = '';
  182.                 if( $posts->have_posts() ) :
  183.                     while( $posts->have_posts() ) : $posts->the_post();
  184.                
  185.                     $i++;
  186.                     // fixes the margin of each 3rd product in the loop (instead of using jQuery)
  187.                     if (($i % 3) == 0) $style = ' style="margin-right: 0px;" '; else $style = '';
  188.                 ?>
  189.                     <div class="omc-product-listing" <?php echo $style; ?>>
  190.                         <a href="<?php the_permalink();?>">
  191.                            
  192.                             <?php
  193.                                 if(has_post_thumbnail()) {
  194.                                 the_post_thumbnail('product', array('class' => 'omc-product-frame'));  
  195.                                 } else {
  196.                             ?>
  197.                            
  198.                             <img src="<?php echo get_template_directory_uri() ;?>/images/no-image.png" width="170" height="170" class="omc-product-frame" alt="no photo" />
  199.                            
  200.                             <?php } ?>
  201.                            
  202.                         </a>
  203.                    
  204.                         <span class="omc-listing-header"><a href="<?php the_permalink();?>"><?php the_title();?></a></span>
  205.                         <span class="omc-listing-price"><?php echo($price);?></span>
  206.                         <span class="omc-listing-more"><a href="<?php the_permalink();?>">&raquo;</a></span>
  207.                     </div><!-- /omc-product-listing -->
  208.                 <?php
  209.                
  210.                     endwhile;
  211.                 else:
  212.                
  213.                     echo 'no results';
  214.                
  215.                 endif; wp_reset_query();       
  216.    
  217.             endforeach;
  218.            
  219.         endif; // End looping through children terms
  220.     ?>
  221.     <br class="clear" />
  222.     <div class="product-pagination">
  223.         <?php  kriesi_pagination(); ?> 
  224.     </div>                     
  225.    
  226. </div><!-- /omc-main-left-column -->           
  227.  
  228. <br class="clear" />
  229.  
  230.  
  231. </div><!-- /omc-inner-page-content -->
  232.  
  233.  
  234.  
  235. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement