Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function phi_portfolio($columns, $category, $postcount, $filterm){
- global $post;
- $clickbehaviour = get_option('phi_thumbnail_click');
- $taxonomy = 'phiportfoliocats';
- $posttype = 'phiportfolio';
- $columns = $columns;
- $term = $category;
- $order = get_option('phi_portfolio_order');
- $postcount = $postcount;
- if(!is_single()){
- if (get_option(phi_disable_portfolioexcerpt)!= true):
- $disableexcerpt = 'false';
- endif;
- if ($columns == 5){$imageheight = get_option('phi_fifth_image_height'); $columnclass='one-fifth'; $imagewidth = 'fifth';}
- if ($columns == 4){$imageheight = get_option('phi_fourth_image_height'); $columnclass='one-fourth'; $imagewidth = 'fourth';}
- if ($columns == 3){$imageheight = get_option('phi_third_image_height'); $columnclass='one-third'; $imagewidth = 'third';}
- if ($columns == 2){$imageheight = get_option('phi_half_image_height'); $columnclass='one-half'; $imagewidth = 'half';}
- if ($columns == 1){$imageheight = get_option('phi_post_image_height'); $columnclass=''; $imagewidth = PHI_IMGW_POST;}
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $counter = 0;
- $args = array(
- 'post_type' => 'phiportfolio',
- 'taxonomy' => 'phiportfoliocats',
- 'term' => $term,
- 'paged'=>$paged,
- 'order'=>$order,
- 'showposts'=> $postcount,
- );
- query_posts($args);
- $result;
- if($filter=='true'){
- // GET ALL TERMS FOR TERM MENU
- // Get id of term by it's slug
- $termId = get_term_by( 'slug', $term, $taxonomy );
- $termId = $termId->term_id;
- // Get the terms children
- $termchildren = get_term_children( $termId, $taxonomy );
- // Loop through all the term children and att them to list
- $result.= '<ul id="portfoliofilter">';
- $result.= '<li>'.__('Filter:','itworx').'</li>';
- $result.= '<li><a href="#all" class="portfolio_all">'.__('All','itworx').'</a></li>';
- $px_i = 0;
- foreach ($termchildren as $child) {
- $subterm = get_term_by( 'id', $child, $taxonomy );
- $result.= '<li><a href="#'.$subterm->slug.'" id="'.$subterm->slug.'" class="portfoliofilter">'.$subterm->name.'</a></li>';
- $px_i++;
- }
- $result.= '</ul>';
- }
- $result.='<div class="portfoliowrap">';
- // The loop
- while (have_posts()) : the_post();
- $counter++;
- global $post;
- $category = get_the_category($post->ID);
- foreach ($category as $px_category) :
- echo '<h1>'.$px_category[0]->name.'</h1>';
- endforeach;
- ?>
- <?php
- // Post text
- $customtitle = get_post_meta($post->ID,'phi_customtitle',true);
- $customexcerpt = get_post_meta($post->ID,'phi_customexcerpt',true);
- $video = get_post_meta($post->ID,'phi_lightbox_image',true);
- $text = $post->post_excerpt;
- // Post images
- $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); //Timthumb Resized image
- $wpimage = wp_get_attachment_image_src(get_post_thumbnail_id(), $imagewidth); //WP Resized image
- if($video){$lightbox = $video;}
- else{$lightbox = $image[0];}
- //Get posts terms
- $postSubTerms = get_the_terms($post->ID, $taxonomy);
- // Loop over each item since it's an array
- if($postSubTerms){
- foreach( $postSubTerms as $subTerm ) {
- // Print the name method from $term which is an OBJECT
- $subTermClass= $subTerm->slug;
- $subTermName= $subTerm->name;
- // Get rid of the other data stored in the object, since it's not needed
- }
- unset($postSubTerms);
- }
- if($columns > 1){
- // Grid portfolio
- $result.= '<div class="pf '.$subterm->name. ' ' .$columnclass.' '.$subTermClass.'" ';
- if(get_option('phi_disable_portfolioexcerpt')==false){
- $result.= 'title="'.phi_custom_excerpt($text, get_option('phi_portfolio_charlimit'));
- }
- $result.='">';
- $result.= phi_post_image($imagewidth,'return',$clickbehaviour);
- $result.= '<p class="title"><a href="'.get_permalink().'">'.get_the_title().'</a></p>';
- $subTerms = get_the_terms($post->ID, $taxonomy);
- $result .= '<p class="cats">';
- $termcount = 0;
- $result.= $divider . $subTerm->name;
- $result .= '</p>';
- $result.= '</div>';
- //if(($counter % $columns) == 0){$result.= '<br class="break" />';}
- }
- else{
- // List portfolio
- $result.= '<div class="pfl portfolio-post '.$subTermClass.'">';
- $result.= '<div class="portfolio-image">';
- $result.= phi_post_image('post','return',$clickbehaviour);
- $result.= '</div>';
- $result.= '<div class="portfolio-info">';
- $result.= '<h2><a href="'.get_permalink().'">';
- $result.= get_the_title();
- $result.= '</a></h2>';
- if($disableexcerpt == true){
- $result.= '<p>'.get_the_excerpt().'</p>';
- }
- $result.= '<a href="'.get_permalink().'" class="button">'.__('Read more','itworx').'</a>';
- $result.= '</div>';
- $result.= '</div>';
- }
- endwhile;
- $result.= wp_pagenavi_return();
- $result.= '</div>';
- wp_reset_query();
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement