<?php
if ( ! defined( 'ABSPATH' ) ) {
          header( 'Status: 403 Forbidden' );
          header( 'HTTP/1.1 403 Forbidden' );
          exit;
} // Exit if accessed directly
function gd_latest_coupon_display($gd_latest_coupon){
	?>
<div class="latest_coupon_div">
  <hr>
  <div class="latest_coupon_heading"><span>
    <h4>Latest Web Hosting Coupon</h4>
    </span><br>
    <span class="f-italic">Use latest web hosting coupons to avail discount in your billing while purchase any hosting</span> </div>
  <div class="latest_coupon_boxes">
    <?php 
  		$args = array('posts_per_page' => 6,'post_status'    => 'publish','post_type'=> 'greedycoupon',			
			'order'     => 'DSC', 
	            );
query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
$post_id=get_the_ID();
$coupons_all=get_post_meta($post_id, 'coupons_code', true);
$a=get_post_meta($post_id, 'coupon_count', true);
$a=$a-2;
if(strlen($coupons_all)>5){
			$coupons_all=json_decode($coupons_all,true);
		}
?>
    <div class="coupon_box_out">
      <div class="coupon_box">
        <div class="thumb_img"> <span class="discount_label"> <span class="discount_text"> <?php echo $coupons_all['discount']['coupon_'.$a.'_discount'];?> </span> <img class="discount_sticker" src="<?php echo GRD_PLUGIN_URL;?>/assets/images/discount-sticker.png"> </span>
          <div class="thumb_img_box"><img class="coupon_logo" src="<?php echo the_post_thumbnail_url( 'full' );?>"></div>
        </div>
        <div class="coupon_meta"> <span class="updated"><i class="fa fa-clock-o"></i> Last Update:
          <?php the_modified_date();?>
          </span> </div>
        <div class="coupon_btn"><a href="<?php the_permalink();?>" class="coupon_btn_green">Get Coupon</a></div>
      </div>
    </div>
    <?php 
endwhile;
// Reset Query
wp_reset_query();
			?>
  </div>
</div>
<?php
return $gd_latest_coupon;
}
add_shortcode('gd_latest_coupon','gd_latest_coupon_display');
