Rabat: Today’s Deals

Today i’m gonna share a new trick for your Rabat WordPress theme. This theme can be used to share a coupons, very similar to groupons. Even though this theme is really great, i think there is some feature missing within the theme.

The missing feature is: today’s deals. With this feature your customers/visitors can easily check how many coupons submitted today and also what coupons are available for today.

To do it, you can simply copy the code below:

 * Template Name: Today's Deals

<?php get_header(); ?>

 * Partial Template for Latest Coupons
global $featured_coupon_ids;
$featured_coupon_ids = array();
$today = getdate();
$coupons = new WP_Query(array(
  'post_type' => COLABS_POST_TYPE,
  'year' => $today['year'],
  'monthnum' => $today['mon'],
  'day' => $today['mday'],
  'posts_per_page' => get_option( 'colabs_featured_coupon_number' ) ? get_option( 'colabs_featured_coupon_number' ) : 20,
  'meta_query' => array(
      'key' => 'colabs_featured',
      'value' => 'true'

$counter = 1;
$item_per_column = get_option( 'colabs_featured_coupon_item_per_slide' ) ? get_option( 'colabs_featured_coupon_item_per_slide' ) : 8;
$total_coupons = $coupons->found_posts;

<?php if( $coupons->have_posts() ) : ?>
  <section class="list-featured-wrapper list-coupon-wrapper no-paging">
    <div class="head-title">
      <h1> <?php _e('Deals Today', 'colabsthemes'); ?></h1>
      <span class="head-tagline"><?php echo get_option('colabs_featured_coupon_subtitle'); ?></span>
    <div class="list-featured">
      <div class="featured-coupon-slider">
        <?php while( $coupons->have_posts() ) : $coupons->the_post(); ?>
            // Divide item into several columns, depends on item per columns
            if( $counter == 1 )
              echo '<div class="featured-carousel-item">';

            get_template_part( 'content', 'coupon' );

            if( $counter % $item_per_column == 0 )
              echo '</div><div class="featured-carousel-item">';

            if( $counter == $total_coupons )
              echo '</div>';


            // Save featured coupon ids to transients
            $featured_coupon_ids[] = $post->ID;

        <?php endwhile; 

        $featured_transient = get_transient( 'colabs_featured_coupon_ids' );
        if( $featured_transient != $featured_coupon_ids ) {
          set_transient( 'colabs_featured_coupon_ids', $featured_coupon_ids, 60 * 60 * 24 * 7 );
      </div><!-- .featured-coupon-slider -->

  </section><!-- .list-featured-wrapper -->
<?php endif; wp_reset_postdata(); ?>

<?php get_footer(); ?>

Since this is about creation a new page template, paste the code into  a new file (you can named it with any name you want, for example: template-todays-deals.php).

Once you made the file, upload it via FTP to directory: wp-content → themes → rabat. Then you can create a new page using a page template you just made (the template name will be today’s deals). And done!

This page will displaying all today’s submitted coupons, the time will following your server configuration.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s