Advertisement
deliciousthemes

Haze - New Portfolio Page

Feb 18th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.42 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4. Template Name: Portfolio
  5.  
  6.  */
  7. global $data;
  8.  
  9. function chs($string)
  10. {
  11.     return preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8'));
  12. }
  13.  
  14. ?>
  15. <?php get_header(); ?>
  16.  
  17.         <section class="page-title">
  18.             <div class="double-separator"></div>
  19.             <div class="breadcrumbs">
  20.                 <div class="one-third align-left">
  21.                     <?php if (function_exists('dt_breadcrumbs')) dt_breadcrumbs(); ?>
  22.                 </div>
  23.                
  24.                 <div class="two-third column-last align-right">        
  25.                     <?php
  26.                         $categs = get_post_meta($post->ID,'haze_cats_field');
  27.                         $layout = get_post_meta($post->ID,'haze_portfolio_columns',true);
  28.                         $navig = get_post_meta($post->ID,'haze_portfolio_navigation',true);
  29.                         $nav_number = get_post_meta($post->ID,'haze_nav_number',true);             
  30.                        
  31.                             $i=0;
  32.                             $count =0;
  33.                             $term_list ='';    
  34.                             $list = '';
  35.                             foreach ($categs as $categ) {
  36.                                 $i++;
  37.                                
  38.                                 $to_replace = array(' ', '/', '&');
  39.                                 $intermediate_replace = strtolower(str_replace($to_replace, '-', $categ));
  40.                                 $str = preg_replace('/--+/', '-', $intermediate_replace);
  41.                                 $str=chs($str); echo $str;
  42.                                 $term_list .= '<li class=""><a href="#" data-value="'. $str .'" class="dt-'. $str .'">' . $categ . '</a></li>';
  43.                                 $list .= $categ . ', ';
  44.                                 if ($count != $i)
  45.                                 {
  46.                                     $term_list .= '';
  47.                                 }
  48.                                 else
  49.                                 {
  50.                                     $term_list .= '';
  51.                                 }
  52.                             }
  53.                                 if (($i > 1) && ($navig == 'filter')) { ?>
  54.                                     <ul id="filters">
  55.                                         <li><?php _e('Sort By: ', 'haze'); ?></li> 
  56.                                         <li class="selected active"><a data-value="all" href="#">All</a></li>
  57.                                    
  58.                                     <?php  
  59.                                     echo $term_list; ?>
  60.                                     </ul>
  61.                                     <?php
  62.                                 }      
  63.                                 else if (($i = 1) && ($navig == 'filter')) { ?>
  64.                                     <ul id="filters">
  65.                                     <?php  
  66.                                     echo $categ; ?>
  67.                                     </ul>
  68.                                     <?php
  69.                                 }                              
  70.                                
  71.                                
  72.                        
  73.                     ?>
  74.                 </div>
  75.             </div><!--end breadcrumbs-->
  76.             <div class="double-separator"></div>
  77.         </section>
  78.     </div><!--end top-->
  79.  
  80.     <div class="centered-wrapper">
  81.  
  82.         <section id="portfolio-wrapper">
  83.             <ul class="portfolio <?php echo $layout; ?>">
  84.            
  85.                 <?php
  86.                     $show_number = '-1';
  87.                 if ($navig == 'no-filter') {
  88.                     if (!empty($nav_number)) {
  89.                         $show_number = $nav_number;
  90.                     }
  91.                     else $show_number = 8;
  92.                 }
  93.                
  94.                 //get post type - portfolio
  95.                 query_posts(array(
  96.                     'post_type'=>'portfolio',
  97.                     'posts_per_page' => $show_number,
  98.                     'term' => 'portfolio_cats',
  99.                     'portfolio_cats' => $list,
  100.                     'paged'=>$paged
  101.                 ));
  102.  
  103.                 // Begin The Loop
  104.                 if (have_posts()) : while (have_posts()) : the_post();         
  105.  
  106.                 // Get The Taxonomy 'Filter' Categories
  107.                 $terms = get_the_terms( get_the_ID(), 'portfolio_cats' );
  108.  
  109.                 //Apply a data-id for unique indentity,
  110.                 //and loop through the taxonomy and assign the terms to the portfolio item
  111.                 // which will be referenced to Quicksand
  112.  
  113.                 ?>
  114.                 <li data-id="id-<?php echo $count; ?>" class="portfo <?php if($terms) { foreach ($terms as $term) {
  115.  
  116.                
  117.                     $new_to_replace = array(' ', '/', '&');
  118.                     $new_intermediate_replace = strtolower(str_replace($new_to_replace, '-', $term->name));
  119.                     $new_str = preg_replace('/--+/', '-', $new_intermediate_replace);              
  120.                     $new_str=chs($new_str);
  121.                    
  122.                     echo $new_str .' ';
  123.                
  124.                 } } else { echo 'none'; } ?>">
  125.                          
  126.                     <?php  
  127.                         // Check if wordpress supports featured images, and if so output the thumbnail
  128.                     if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) :
  129.                        
  130.                         // Output the featured image ?>
  131.                         <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('portfolio-thumb'); ?></a>
  132.                        
  133.                     <?php endif; ?>
  134.                        
  135.                     <?php // Output the title of each portfolio item ?>
  136.                     <h4><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></h4>
  137.                     <?php the_excerpt(); ?>
  138.                     <div class="count hidden"></div>
  139.                 </li>
  140.  
  141.                 <?php $count++; // Increase the count by 1 ?>      
  142.                 <?php endwhile; endif; // END the Wordpress Loop ?>    
  143.             </ul>      
  144.             <?php dt_navigation(); ?>
  145.             <?php wp_reset_query(); // Reset the Query Loop ?>                 
  146.         </section>
  147.  
  148.     </div><!--end centered-wrapper-->
  149.  
  150. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement