Advertisement
Guest User

loop-portfolio.php

a guest
Sep 19th, 2013
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.14 KB | None | 0 0
  1. <?php
  2. /*
  3. * The Loop for portfolio overview pages. Works in conjunction with the file template-portfolio.php and taxonomy-portfolio_entries.php
  4. */
  5.  
  6.  
  7.  
  8. global $avia_config, $wp_query;
  9. if(isset($avia_config['new_query'])) { query_posts($avia_config['new_query']); }
  10.  
  11.  
  12. $loop_counter = 1;
  13. // check if we got a page to display:
  14. if (have_posts()) :
  15.    
  16.     $extraClass = 'first';
  17.     $style = 'portfolio-entry-no-description';
  18.    
  19.     $grid = 'one_fourth';
  20.     $image_size = 'portfolio';
  21.  
  22.    
  23.    
  24.     switch($avia_config['portfolio_columns'])
  25.     {
  26.         case "1": $grid = 'fullwidth';  $image_size = 'fullsize'; break;
  27.         case "2": $grid = 'one_half';   break;
  28.         case "3": $grid = 'one_third';  break;
  29.         case "4": $grid = 'one_fourth'; break;
  30.     }
  31.    
  32.     $avia_config['portfolio_columns_iteration'] = $avia_config['portfolio_columns'][0];
  33.     if(!isset($avia_config['remove_portfolio_text'])) $style = 'portfolio-entry-description';
  34.    
  35.    
  36.     $includeArray = "";
  37.     if(isset($avia_config['new_query']['tax_query'][0]['terms'])) $includeArray = $avia_config['new_query']['tax_query'][0]['terms'];
  38.    
  39.     $args = array(
  40.    
  41.         'taxonomy'  => 'portfolio_entries',
  42.         'hide_empty'=> 0,
  43.         'include'   => $includeArray
  44.    
  45.     );
  46.  
  47.     $categories = get_categories($args);
  48.     $container_id = "";
  49.    
  50.     $current_page_cats = array();
  51.     while (have_posts()){
  52.         the_post();
  53.         $current_item_cats = get_the_terms( $id, 'portfolio_entries' );
  54.         if(!empty($current_item_cats))
  55.         {
  56.             foreach($current_item_cats as $current_item_cat)
  57.             {
  58.                 $current_page_cats[] = $current_item_cat->term_id;
  59.             }
  60.         }
  61.     }
  62.     $current_page_cats = array_unique($current_page_cats);
  63.    
  64.    
  65.     if(!isset($avia_config['portfolio_sorting']) || $avia_config['portfolio_sorting'] == 'yes')
  66.     {
  67.  
  68.    
  69.         if(!empty($categories[0]))
  70.         {
  71.             $output = "<div id='js_sort_items' >";
  72.    
  73.             $hide = "hidden";
  74.             if (isset($categories[1])){ $hide = ""; }
  75.            
  76.             $output .= "<div class='sort_by_cat $hide '>";
  77.             $output .= "<a href='#' data-filter='all_sort' class='active_sort'>".__('All','avia_framework')."</a>";
  78.            
  79.             foreach($categories as $category)
  80.             {
  81.                 if(in_array($category->term_id, $current_page_cats, true))
  82.                 {
  83.                 $output .= "<span class='text-sep'>/</span><a href='#' data-filter='".$category->category_nicename."_sort'>".$category->cat_name."</a>";
  84.                 $container_id .= $category->term_id;
  85.                 }
  86.             }
  87.            
  88.             $output .= "</div>";
  89.            
  90.    
  91.             $output .= "</div>";
  92.            
  93.             echo $output;
  94.         }
  95.     }
  96.    
  97.  
  98.     echo "<div class='portfolio-sort-container'>"; 
  99.     //iterate over the posts
  100.     while (have_posts()) : the_post(); 
  101.    
  102.     //get the categories for each post and create a string that serves as classes so the javascript can sort by those classes
  103.     $sort_classes = "";
  104.     $item_categories = get_the_terms( $id, 'portfolio_entries' );
  105.  
  106.     if(is_object($item_categories) || is_array($item_categories))
  107.     {
  108.         foreach ($item_categories as $cat)
  109.         {
  110.             $sort_classes .= $cat->slug.'_sort ';
  111.         }
  112.     }
  113.        
  114.  
  115. ?>
  116.  
  117.        
  118.         <div class='post-entry flex_column all_sort <?php echo $sort_classes.' '.$grid.' '.$extraClass.' '.$style; ?>'>
  119.                                                        
  120.             <?php
  121.                 $forceSmall = true;
  122.                 $slider = new avia_slideshow(get_the_ID());
  123.                 $slider -> setImageSize($image_size);
  124.                 echo $slider->display($forceSmall);
  125.            
  126.            
  127.             //$showcaption
  128.            
  129.             if(!isset($avia_config['remove_portfolio_text']))
  130.             {
  131.                 echo '<div class="post-content">';
  132.                 echo "<h1 class='post-title'>";
  133.                 $slides = avia_post_meta(get_the_ID(), 'slideshow');
  134.  
  135.                     if(!empty($slides[0])){
  136.                     $linktarget = avia_get_link($slides[0], 'slideshow_', '', get_the_ID());
  137.                     }
  138.                    
  139.                     if(empty($linktarget)){
  140.                     $linktarget = get_permalink();
  141.                     }
  142.                    
  143.                     echo "<a href='".$linktarget."' rel='bookmark' title='".__('Permanent Link:','avia_framework')." ".get_the_title()."'>".                get_the_title()."</a>";
  144.                 echo "</h1>";
  145.                
  146.                 echo '<div class="entry-content">';
  147.                      
  148.                 if($avia_config['portfolio_columns_iteration'] == 1)
  149.                 {
  150.                     echo '<span class="portfolio-categories minor-meta">';
  151.                     echo get_the_term_list(  get_the_ID(), 'portfolio_entries', '<strong>'.__('Categories','avia_framework').': </strong><span>', '</span><span class="text-sep">/</span><span>','</span>');
  152.                     echo '</span>';
  153.  
  154.                 }
  155.                
  156.                 the_excerpt();
  157.                 echo '<a class="more-link" href="'.$linktarget.'">'.__('Read more  →','avia_framework').'</a>';
  158.                 echo "</div>";
  159.                 echo "</div>";
  160.                
  161.             }
  162.             else
  163.             {
  164.                 $hr_class = 'hr hr_invisible';
  165.             }
  166.              
  167.         ?>                     
  168.         <!-- end post-entry-->
  169.         </div>
  170.    
  171.     <?php
  172.  
  173.     $loop_counter++;
  174.     $extraClass = "";
  175.  
  176.     if($loop_counter > $avia_config['portfolio_columns_iteration'])
  177.     {
  178.         $loop_counter = 1;
  179.         $extraClass = 'first';
  180.     }
  181.  
  182.  
  183.     endwhile;
  184.    
  185.     echo "</div>";  // end portfolio-sort-container
  186.  
  187.    
  188.    
  189.     if(!isset($avia_config['remove_pagination'] ))
  190.     {
  191.         echo "<div class='hr hr_invisible'></div>";
  192.         echo avia_pagination();
  193.     }  
  194.     echo "<!-- end -->"; //dont remove
  195.     else:
  196. ?> 
  197.    
  198.     <div class="entry">
  199.         <h1 class='post-title'><?php _e('Nothing Found', 'avia_framework'); ?></h1>
  200.         <p><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p>
  201.     </div>
  202. <?php
  203.  
  204.    
  205.  
  206.  
  207.     endif;
  208.    
  209.        
  210. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement