OHIDUL951

portfolio-template

May 23rd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.90 KB | None | 0 0
  1.     <?php
  2.             // Query for all the portfolio posts
  3.             $args = array(
  4.                 'post_type' => 'portfolio',
  5.                 'posts_per_page'   => $limit,
  6.             );
  7.  
  8.             $posts = new WP_Query( $args );
  9.  
  10.             if( $posts->have_posts() ) :
  11.     ?>
  12.         <div class="portfolio-containered">
  13.             <div class="portfolio-wrapper">
  14.                
  15.                 <?php if( $pf_switch == 'yes' ) : ?>
  16.  
  17.                 <div class=" <?php echo implode(' ', $portfolio_filter_class); ?>">
  18.                    
  19.                     <button class="active button-flt" data-filter="*">all work</button>
  20.  
  21.                     <?php
  22.                         $terms = get_terms( 'portfolio-type' );
  23.                         $count = count( $terms );
  24.                         if ( $count > 0 ) {
  25.                             foreach ( $terms as $term ) {
  26.                                 echo '<button class="button-flt" data-filter=".'. esc_attr( strtolower( $term->name ) ) .'">'. esc_attr( strtolower( $term->name ) ) .'</button>';
  27.                             }
  28.                         }
  29.                     ?>
  30.                        
  31.                 </div>
  32.                 <?php endif; ?>
  33.  
  34.                 <div class="portfolio portfolio-gutter portfolio-masonry  portfolio-3-column hover-with-border portfolio-ajax">
  35.        
  36.                 <?php
  37.                         while( $posts->have_posts() ) :
  38.                         $posts->the_post();
  39.  
  40.                         // Get taxonomies for single portfolio posts
  41.                         $types      = get_the_terms( $posts->ID, 'portfolio-type' );
  42.                         $typesCount = count( $types );
  43.                         $count      = 0;
  44.                         $termArr = array();
  45.  
  46.                         // Loop over throuth each the terms
  47.                         if( $types ) {
  48.                             foreach($types as $type) {
  49.                                     $termArr[] = strtolower( $type->name ) ;
  50.                             }
  51.                         }
  52.  
  53.                 ?>
  54.                
  55.                     <div class="portfolio-item  <?php  echo implode(' ', $termArr); ?> ">
  56.                         <div class="portfolio-item-content">
  57.                             <?php if ( has_post_thumbnail() ) : ?>
  58.                                 <div class="item-thumbnail">
  59.                                     <?php the_post_thumbnail( $posts->ID , 'maxive-portfolio-img-large'); ?>
  60.                                 </div>
  61.                             <?php else: ?>
  62.                                 <div class="item-thumbnail">
  63.                                     <img src="<?php echo get_template_directory_uri(); ?>/assets/img/placeholder-image.jpg" alt="">
  64.                                 </div>
  65.                             <?php endif; ?>
  66.                             <div class="portfolio-description">
  67.                                 <h4><a href="#" ><?php the_title(); ?></a></h4>
  68.                                 <span class="portfolio-category">
  69.                                     <?php
  70.                                         // Increment the counter
  71.                                         $count++;
  72.  
  73.                                         echo  implode(', ', $termArr);
  74.  
  75.                                     ?>
  76.                                 </span>
  77.                             </div>
  78.                         </div>
  79.                     </div>
  80.  
  81.  
  82.  
  83.                 <?php
  84.  
  85.                     endwhile;
  86.                     wp_reset_postdata();
  87.                 ?>
  88.  
  89.                 </div>
  90.  
  91.                 <div class="col-md-12 text-center pt-20 pf-load-more-wrapper">
  92.                     <a href="#" class="maxive-pf-load-more" data-pf-object='<?php echo  $maxive_pf_ajax_options; ?>'>LOAD MORE +</a>
  93.                 </div>
  94.             </div>
  95.         </div>
  96.  
  97.     <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment