Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.81 KB | None | 0 0
  1. function phi_portfolio($columns, $category, $postcount, $filterm){
  2. global $post;
  3. $clickbehaviour = get_option('phi_thumbnail_click');
  4.  
  5. $taxonomy = 'phiportfoliocats';
  6. $posttype = 'phiportfolio';
  7. $columns = $columns;
  8. $term = $category;
  9. $order = get_option('phi_portfolio_order');
  10. $postcount = $postcount;
  11.  
  12.  
  13.  
  14.  
  15. if(!is_single()){
  16. if (get_option(phi_disable_portfolioexcerpt)!= true):
  17. $disableexcerpt = 'false';
  18. endif;
  19.  
  20.  
  21. if ($columns == 5){$imageheight = get_option('phi_fifth_image_height'); $columnclass='one-fifth'; $imagewidth = 'fifth';}
  22. if ($columns == 4){$imageheight = get_option('phi_fourth_image_height'); $columnclass='one-fourth'; $imagewidth = 'fourth';}
  23. if ($columns == 3){$imageheight = get_option('phi_third_image_height'); $columnclass='one-third'; $imagewidth = 'third';}
  24. if ($columns == 2){$imageheight = get_option('phi_half_image_height'); $columnclass='one-half'; $imagewidth = 'half';}
  25. if ($columns == 1){$imageheight = get_option('phi_post_image_height'); $columnclass=''; $imagewidth = PHI_IMGW_POST;}
  26.  
  27.  
  28.    
  29. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  30. $counter =  0;
  31.  
  32. $args = array(
  33. 'post_type' => 'phiportfolio',
  34. 'taxonomy' => 'phiportfoliocats',
  35. 'term' => $term,
  36. 'paged'=>$paged,
  37. 'order'=>$order,
  38. 'showposts'=> $postcount,
  39. );
  40.  
  41. query_posts($args);
  42.  
  43. $result;
  44. if($filter=='true'){
  45. // GET ALL TERMS FOR TERM MENU
  46. // Get id of term by it's slug
  47. $termId = get_term_by( 'slug', $term, $taxonomy );
  48. $termId = $termId->term_id;
  49. // Get the terms children
  50. $termchildren = get_term_children( $termId, $taxonomy );
  51. // Loop through all the term children and att them to list
  52.  
  53. $result.= '<ul id="portfoliofilter">';
  54. $result.= '<li>'.__('Filter:','itworx').'</li>';
  55. $result.= '<li><a href="#all" class="portfolio_all">'.__('All','itworx').'</a></li>';
  56. $px_i = 0;
  57. foreach ($termchildren as $child) {
  58.     $subterm = get_term_by( 'id', $child, $taxonomy );
  59.     $result.= '<li><a href="#'.$subterm->slug.'" id="'.$subterm->slug.'" class="portfoliofilter">'.$subterm->name.'</a></li>';
  60.     $px_i++;
  61. }
  62. $result.= '</ul>';
  63. }
  64.  
  65. $result.='<div class="portfoliowrap">';
  66.  
  67. // The loop
  68. while (have_posts()) : the_post();  
  69. $counter++;
  70. global $post;
  71. $category = get_the_category($post->ID);
  72.  
  73. foreach ($category as $px_category) :
  74.     echo '<h1>'.$px_category[0]->name.'</h1>';
  75. endforeach;
  76. ?>
  77.  
  78. <?php
  79. // Post text
  80. $customtitle = get_post_meta($post->ID,'phi_customtitle',true);
  81. $customexcerpt = get_post_meta($post->ID,'phi_customexcerpt',true);
  82. $video = get_post_meta($post->ID,'phi_lightbox_image',true);
  83. $text = $post->post_excerpt;
  84. // Post images
  85. $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');         //Timthumb Resized image
  86. $wpimage = wp_get_attachment_image_src(get_post_thumbnail_id(), $imagewidth); //WP Resized image
  87.  
  88. if($video){$lightbox = $video;}
  89. else{$lightbox = $image[0];}
  90.  
  91.  
  92.            
  93.             //Get posts terms
  94.             $postSubTerms = get_the_terms($post->ID, $taxonomy);  
  95.             // Loop over each item since it's an array
  96.                 if($postSubTerms){
  97.                 foreach( $postSubTerms as $subTerm ) {
  98.                 // Print the name method from $term which is an OBJECT
  99.                 $subTermClass= $subTerm->slug;
  100.                 $subTermName= $subTerm->name;
  101.                 // Get rid of the other data stored in the object, since it's not needed
  102.                 }
  103.                
  104.                 unset($postSubTerms);
  105.                
  106.                 }
  107.            
  108.            
  109.             if($columns > 1){  
  110.             // Grid portfolio
  111.             $result.= '<div class="pf '.$subterm->name. ' ' .$columnclass.' '.$subTermClass.'" ';
  112.             if(get_option('phi_disable_portfolioexcerpt')==false){
  113.             $result.= 'title="'.phi_custom_excerpt($text, get_option('phi_portfolio_charlimit'));
  114.             }
  115.             $result.='">';
  116.             $result.= phi_post_image($imagewidth,'return',$clickbehaviour);
  117.  
  118.             $result.=  '<p class="title"><a href="'.get_permalink().'">'.get_the_title().'</a></p>';
  119.                 $subTerms = get_the_terms($post->ID, $taxonomy);
  120.            
  121.             $result .= '<p class="cats">';
  122.             $termcount = 0;
  123.             $result.=  $divider . $subTerm->name;
  124.             $result .= '</p>';
  125.             $result.= '</div>';
  126.                 //if(($counter % $columns) == 0){$result.= '<br class="break" />';}
  127.             }
  128.            
  129.             else{
  130.             // List portfolio
  131.             $result.= '<div class="pfl portfolio-post '.$subTermClass.'">';
  132.            
  133.             $result.= '<div class="portfolio-image">';
  134.             $result.= phi_post_image('post','return',$clickbehaviour);
  135.             $result.= '</div>';
  136.             $result.= '<div class="portfolio-info">';
  137.            
  138.             $result.= '<h2><a href="'.get_permalink().'">';
  139.                
  140.                
  141.             $result.= get_the_title();
  142.             $result.= '</a></h2>';
  143.             if($disableexcerpt == true){
  144.                 $result.= '<p>'.get_the_excerpt().'</p>';
  145.                 }
  146.             $result.= '<a href="'.get_permalink().'" class="button">'.__('Read more','itworx').'</a>';
  147.             $result.= '</div>';
  148.             $result.= '</div>';
  149.             }
  150.            
  151.             endwhile;
  152.  
  153.                        
  154.             $result.= wp_pagenavi_return();
  155.             $result.= '</div>';
  156.             wp_reset_query();      
  157.             return $result;
  158.             }
  159.            
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement