Advertisement
deliciousthemes

Line - Homepage Portfolio Carousel from Specific Categories

Apr 12th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.02 KB | None | 0 0
  1. <?php global $data; ?>
  2.     <section>
  3.         <?php
  4.         if(!empty($data['portfolio_title'])) {
  5.         ?>
  6.             <div class="bgtitle"><h2><?php _e($data['portfolio_title'],'line'); ?></h2></div>
  7.         <?php } ?>
  8.        
  9.         <ul id="mycarousel">
  10.             <?php
  11.             if(!empty($data['portfolio_number'])) {
  12.                 $portfolio_nr = $data['portfolio_number'];
  13.             }
  14.             else {
  15.                 $portfolio_nr = -1;
  16.             }
  17.  
  18.             $args = array(
  19.                 'orderby'=> 'post_date',
  20.                 'order' => 'rand',
  21.                 'post_type' => 'portfolio',
  22.                 'portfolio_cats' => 'branding',
  23.                 'posts_per_page' => $portfolio_nr
  24.             );
  25.            
  26.             $my_query = new WP_Query($args);
  27.             if( $my_query->have_posts() ) {
  28.                 while ($my_query->have_posts()) : $my_query->the_post();
  29.                
  30.                 $p_icon = get_post_meta($post->ID,'dt_portf_icon',true);   
  31.                 $thumb_ids = get_post_thumbnail_id($post->ID);
  32.  
  33.                 $pthumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'portfolio-thumb');
  34.                 ?>
  35.                
  36.                 <li>
  37.  
  38.                     <?php
  39.                     $portf_icon = get_post_meta($post->ID,'dt_portf_icon',true);                       
  40.                     $thumb_id = get_post_thumbnail_id($post->ID);
  41.                    
  42.                     // Check if wordpress supports featured images, and if so output the thumbnail
  43.                     if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) :
  44.                    
  45.                         if ($portf_icon == 'lightbox_to_image') {  ?>
  46.                         <a href="<?php echo wp_get_attachment_url($thumb_id);?>" rel="prettyPhoto">
  47.                             <span class="item-on-hover">
  48.                                 <span class="hover-image"></span>
  49.                             </span>
  50.                             <?php the_post_thumbnail('portfolio-thumb'); ?>
  51.                         </a>
  52.                        
  53.                         <?php }
  54.                         else if ($portf_icon == 'link_to_page') {  ?>
  55.                         <a href="<?php the_permalink(); ?>">
  56.                             <span class="item-on-hover">
  57.                                 <span class="hover-link"></span>
  58.                             </span>
  59.                             <?php the_post_thumbnail('portfolio-thumb'); ?>
  60.                         </a>
  61.                        
  62.                         <?php }        
  63.  
  64.                         else if ($portf_icon == 'lightbox_to_video') {
  65.                        
  66.                             $portfolio_slide = get_post_meta($post->ID,'dt_slider_repeat',true);
  67.                                 if(!empty($portfolio_slide)) {
  68.                                     $get_video = array();
  69.                                     $j=0;
  70.                                     foreach ($portfolio_slide as $slide){
  71.                                         $video = $slide['dt_video_field_id'];
  72.                                         if (!empty($video)) {
  73.                                             $get_video[$j] = $video;
  74.                                             $j++;
  75.                                         }
  76.                                        
  77.                                     }                                  
  78.                                 }
  79.                         ?>
  80.                             <a href='<?php
  81.                                 $input_string = $get_video[0];
  82.                                 $count = preg_match('/src=(["\'])(.*?)\1/', $input_string, $match);
  83.                                 if ($count === FALSE)
  84.                                     echo('not found\n');
  85.                                 else
  86.                                     echo($match[2] . "\n");
  87.                             ?>'>
  88.                                 <span class="item-on-hover">
  89.                                     <span class="hover-video"></span>
  90.                                 </span>
  91.                                 <?php the_post_thumbnail('portfolio-thumb'); ?>
  92.                             </a>
  93.                        
  94.                         <?php }                                
  95.  
  96.                     endif; ?>  
  97.                        
  98.                     <?php // Output the title of each portfolio item ?>
  99.                     <span class="caption"><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></span>                
  100.                 </li>
  101.                 <?php endwhile; wp_reset_query(); } ?>
  102.         </ul>
  103.     </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement