<?php
global $smof_data;
	 $querydetails = "
	   SELECT wposts.*
	   FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
	   WHERE wposts.ID = wpostmeta.post_id
	   AND wpostmeta.meta_key = 'lioit_slider4'
	   AND wpostmeta.meta_value = '1'
	   AND wposts.post_status = 'publish'
	   AND wposts.post_type = 'post'
	   ORDER BY wposts.post_date DESC
	 ";

	 $pageposts = $wpdb->get_results($querydetails, OBJECT);
	 
	 
	 if ($pageposts == true){
?>


<div id="slider-container">
          <div class="container"> 
            <!-- Slides MUST BE 5 -->
            <div class="bx-wrapper">
              <div class="bx-viewport">
                <ul id="featured-slider">
                <?php 
                
                                $i = 0;
                                if ($pageposts):
                                foreach ($pageposts as $post):
                                setup_postdata($post); 
                                $i++;
                                if ($i <= 4) {
                                ?>
                  <li class="bx-clone">
                 <div class="bx-caption"><span><?php 
											$badge_text = get_post_meta($post->ID, 'lioit_post_badge_text', true);
											$badge_color = get_post_meta($post->ID, 'lioit_post_badge_color', true);
										?>
                                        <?php if ($badge_text) { ?>
                                        <div class="articleType" style="background-color:<?php echo $badge_color; ?>;"><?php echo $badge_text; ?></div>
                                        <?php } ?><a href="<?php the_permalink();?>"><?php the_title(); ?></a></span>
                    					<ul class="postMeta">
                                        	<?php
                                            $lioit_review_enable =  get_post_meta($post->ID, 'lioit_review_enable', true);
                                            $lioit_review_type =  get_post_meta($post->ID, 'lioit_review_type', true);
                                            $lioit_final_score =  get_post_meta($post->ID, 'lioit_final_score', true);
                                            $lioit_final_percentage = $lioit_final_score * 20 ;
                                        	?>
                                        	<?php if($lioit_review_enable == 'enable'){ ?>
                                            <li>
                                            	<span class="lioit-rating lioit-rating-<?php echo esc_html($lioit_review_type); ?>">
                                                	<span style="width:<?php echo esc_html($lioit_final_percentage); ?>%;"></span>
                                                </span>
                                            </li>
											<?php } ?>
                                        	<li class="postAuthor"><i class="icon-user"></i><?php the_author_posts_link(); ?></li>
                                        	<li class="MetapostDate"><i class="icon-calendar"></i><?php the_time('F d, Y'); ?></li>
                                            <li class="postComments"><i class="icon-comments"></i><a href="<?php comments_link();?>"><?php comments_number('No Comments','1 Comment','% Comments');?></a></li>
                                        </ul><!--End postMeta-->
                                        <p><?php the_excerpt_max_charlength('280'); ?></p>
                                        <a href="<?php the_permalink();?>" class="postMore btn"><?php _e('Read More' , 'lioit' ) ?></a>
                                        </div>
                  
                                            <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('fullimg'); ?></a>
                                              
                  </li>
                  
                  <?php } 
                                    endforeach; 	
                                endif; 
                                wp_reset_query();?>	
                </ul>
              </div>
              <div class="bx-controls"></div>
            </div>
            <!-- Tabs for slides MUST BE 5 -->
            <div id="featured-slider-pager">
            
           
                                        
                                        <?php 
                
                                $i = -1;
                                if ($pageposts):
                                foreach ($pageposts as $post):
                                setup_postdata($post); 
                                $i++;
                                if ($i <= 4) {
                                ?>	
                                        
            <a data-slide-index="<?php echo $i; ?>" href="<?php the_permalink(); ?>" class="">
            <?php the_post_thumbnail('thumb-small', array('title' => strip_tags(get_the_title()))); ?>
              <h3><?php 
											$badge_text = get_post_meta($post->ID, 'lioit_post_badge_text', true);
											$badge_color = get_post_meta($post->ID, 'lioit_post_badge_color', true);
										?>
                                        <?php if ($badge_text) { ?>
                                        <div class="articleType" style="background-color:<?php echo $badge_color; ?>;"><?php echo $badge_text; ?></div>
                                        <?php } ?><?php the_title(); ?></h3>
              <div class="entry-meta">
          		<?php
                                            $lioit_review_enable =  get_post_meta($post->ID, 'lioit_review_enable', true);
                                            $lioit_review_type =  get_post_meta($post->ID, 'lioit_review_type', true);
                                            $lioit_final_score =  get_post_meta($post->ID, 'lioit_final_score', true);
                                            $lioit_final_percentage = $lioit_final_score * 20 ;
                                        	?>
                                        	<?php if($lioit_review_enable == 'enable'){ ?>
                                         
                                            	<span class="lioit-rating lioit-rating-<?php echo esc_html($lioit_review_type); ?>">
                                                	<span style="width:<?php echo esc_html($lioit_final_percentage); ?>%;"></span>
                                                </span>
                                          
											<?php } ?>
                                            <span class="postViews"><i class="icon-eye"></i> <?php echo getPostViews($post->ID); ?></span>
                
               
              </div>
              </a> 
              
               <?php } 
                                    endforeach; 	
                                endif; 
                                wp_reset_query();?>	
             </div>
          </div>
        </div>
        
        <?php }else{ ?>
<?php }?>