danstramer

archive-product.php | CPT Archive

Apr 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  3. $display_type = po_get_display_type();
  4. ?>
  5. <header class="entry-header">
  6.     <?php /*?><?php if ( po_breadcrumbs_need_to_show() ) : ?>
  7.         <?php pojo_breadcrumbs(); ?>
  8.     <?php endif; ?><?php */?>
  9.     <?php if ( ! is_home() && ! is_front_page() ) : ?>
  10.        
  11.     <?php endif; ?>
  12. </header>
  13.  
  14. <?php //start by fetching the terms for the products_category taxonomy
  15. $terms = get_terms( 'products_category', array(
  16.     'orderby'    => 'count',
  17.     'hide_empty' => 0
  18. ) );
  19. ?>
  20.    
  21.     Archive products
  22.    
  23.     <?php if ( have_posts() ) : ?>
  24.     <?php do_action( 'pojo_before_content_loop', $display_type ); ?>
  25.    
  26.      <?php
  27. // now run a query for each product family
  28. foreach( $terms as $term ) {
  29.  
  30.     // Define the query
  31.     $args = array(
  32.         'post_type' => 'products',
  33.         'products_category' => $term->slug
  34.     );
  35.     $query = new WP_Query( $args );
  36.              
  37.     // output the term name in a heading tag                
  38.     echo'<h2>' . $term->name . '</h2>';
  39.      
  40.     // output the post titles in a list
  41.     echo '<ul class="cat">';
  42.      
  43.         // Start the Loop
  44.         while ( $query->have_posts() ) : $query->the_post(); ?>
  45.  
  46.         <li class="product-grid" id="post-<?php the_ID(); ?>">
  47.             <a href="<?php the_permalink(); ?>">
  48.             <div class="image"><?php  if ( has_post_thumbnail() ) {
  49.     the_post_thumbnail('thumbnail');
  50. }?>  </div>
  51.             <h3><?php the_title(); ?></h3></a>
  52.             <div class="product-price"><span>₪</span><?php the_field('price'); ?></div>
  53.            
  54.               <?php
  55.                   //http://wpquestions.com/question/showChrono/id/9730
  56.  
  57.         $values = get_field('features');
  58.         if($values)
  59.         {
  60.             echo '<ul class="features">';
  61.             foreach($values as $value)
  62.             {
  63.                 echo '<li><img src="'.get_bloginfo('stylesheet_directory').'/images/' . $value . '.png"></li>';
  64.  
  65.             }
  66.             echo '</ul>';
  67.         }
  68.         ?>
  69.            
  70.            
  71.         </li>
  72.          
  73.         <?php endwhile;
  74.      
  75.     echo '</ul>';
  76.      
  77.     // use reset postdata to restore orginal query
  78.     wp_reset_postdata();
  79.  
  80. } ?>
  81.    
  82.  
  83.     <?php do_action( 'pojo_after_content_loop', $display_type ); ?>
  84.    
  85. <?php else : ?>
  86.     <?php pojo_get_content_template_part( 'content', 'none' ); ?>
  87. <?php endif; ?>
Add Comment
Please, Sign In to add comment