Advertisement
darrenbachan

content-upcoming-games.php

Jun 17th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.68 KB | None | 0 0
  1. <?php
  2.  
  3. $time = current_time( 'timestamp' ); // Get current unix timestamp
  4.  
  5. $cpt_posts_per_page = ( is_front_page() ) ? 4 : -1;
  6. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  7.  
  8. $args = array(
  9.         'post_type'                 => 'upcoming-games',
  10.         'post_status'               => 'publish',
  11.         'orderby'                   => 'meta_value',
  12.         'meta_key'                  => 'release_date',
  13.         'meta_value'                => $time,
  14.         'meta_compare'              => '>=',
  15.         'order'                     => 'ASC',
  16.         'posts_per_page'            => $cpt_posts_per_page,
  17.         'paged'                     => $paged
  18.     );
  19.  
  20.     $upcoming_games = new WP_Query( $args );
  21.  
  22.     ?>
  23.    
  24.         <div class="col-md-12">
  25.             <div class="page-header see-more-header">
  26.                 <h3><?php _e('Upcoming Games', 'content-upcoming-games'); ?></h3>
  27.                 <?php if ( is_front_page() ) { ?>
  28.                     <a href="/upcoming-games/" class="">See All <i class="fa fa-long-arrow-right"></i></a>
  29.                 <?php }
  30.                 ?>
  31.             </div>
  32.         </div>
  33.            
  34.         <?php if ( $upcoming_games->have_posts() ) : ?>
  35.             <div class="col-md-12">
  36.                 <p>Check out some of the games that are coming out in <?php echo Date('Y'); ?>.</p>
  37.             </div>
  38.  
  39.             <div class="controls col-md-12">
  40.                 <label>Sort By:</label>
  41.  
  42.                 <button class="filter" data-filter="all">All</button>
  43.                 <button class="filter" data-filter=".ps4">PS4</button>
  44.                 <button class="filter" data-filter=".xbox-one">Xbox One</button>
  45.                 <button class="filter" data-filter=".wii-u">Wii U</button>
  46.                 <button class="filter" data-filter=".pc">PC</button>
  47.             </div>
  48.            
  49.             <div id="upcoming-games-list" class="col-md-12">
  50.                 <?php while ( $upcoming_games->have_posts() ) : $upcoming_games->the_post(); ?>
  51.                     <?php
  52.                         $class ='';
  53.                         foreach ($consoles as $console) {
  54.                         $class .= $console->slug . ' ';
  55.                         }
  56.                     ?>
  57.                     <div id="<?php the_id(); ?>" class="<?php echo $class ?>mix col-xs-12 col-sm-6 <?php if(is_front_page()) { echo 'col-md-3'; } else { echo 'col-md-3'; } ?> upcoming-game">
  58.                         <?php $box_art = get_field('box_art'); ?>
  59.                         <div class="post-img">
  60.                             <a href="<?php the_permalink(); ?>"><img src="<?php echo $box_art; ?>" alt=""></a>
  61.                         </div>
  62.  
  63.                         <?php
  64.                             $release_date = get_field( "release_date");
  65.  
  66.                             $publisher = get_field( "publisher" );
  67.                             $developer = get_field( "developer" );
  68.                             $youtube_link = get_field( "youtube_link" );
  69.  
  70.                             $label_release_date = get_field_object($release_date);
  71.                         ?>
  72.                        
  73.                         <div class="upcoming-games-meta">
  74.                             <div class="meta-game-title">
  75.                                 <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
  76.                             </div>
  77.                            
  78.                             <ul>
  79.                                 <?php if( !empty ($release_date) ) echo '<li>' . '<span>' . 'Release Date' . ': ' . '</span>' . $release_date . '</li>'; ?>
  80.                                 <?php if( !empty ($publisher) ) echo '<li>' , '<span>', 'Publisher: ' , '</span>' , the_field('publisher') , '</li>'; ?>
  81.                                 <?php if( !empty ($developer) ) echo '<li>' , '<span>', 'Developer: ' , '</span>' , the_field("developer") , '</li>'; ?>
  82.                                 <?php
  83.                                 $genres = wp_get_object_terms( $post->ID,  'genres' );
  84.                                 $separator = ", ";
  85.                                 $output = '';
  86.  
  87.                                 if ( ! empty( $genres ) ) {
  88.                                     if ( ! is_wp_error( $genres ) ) {
  89.                                         echo '<li><span>Genre:</span> ';
  90.                                             foreach( $genres as $term ) {
  91.                                                 $output .= esc_html( $term->name ) . $separator;
  92.                                             } echo trim($output, $separator);
  93.                                         echo '</li>';
  94.                                     }
  95.                                 }
  96.                                 ?>
  97.                                 <?php
  98.                                 $consoles = wp_get_object_terms( $post->ID,  'consoles' );
  99.                                 $separator = ", ";
  100.                                 $output = '';
  101.  
  102.                                 if ( ! empty( $consoles ) ) {
  103.                                     if ( ! is_wp_error( $consoles ) ) {
  104.                                         echo '<li><span>Platforms:</span> ';
  105.                                             foreach( $consoles as $term ) {
  106.                                                 $output .= esc_html( $term->name ) . $separator;
  107.                                             } echo trim($output, $separator);
  108.                                         echo '</li>';
  109.                                     }
  110.                                 }
  111.                                 ?>
  112.                             </ul>
  113.  
  114.                             <div class="meta-comment-counter">
  115.                                 <a href="<?php the_permalink(); ?>#comments"><i class="fa fa-comments"></i> <?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?></a>
  116.                             </div>
  117.                            
  118.                             <?php if( !empty ($youtube_link) ) echo '<div class="meta-trailer">' . '<a class="btn btn-secondary btn-md" href="'. $youtube_link .'" target="_blank">' . '<i class="fa fa-youtube-play"></i>' . 'Watch Trailer' . '</a>' . '</div>'; ?>
  119.                         </div><!--end upcoming games meta text-->
  120.                     </div><!-- end upcoming game -->
  121.                 <?php endwhile; ?>
  122.             </div><!-- end upcoming games -->
  123.  
  124.         <?php else : ?>
  125.             <div class="col-md-12">
  126.                 <p><?php _e( "No Upcoming Games? Well this isn't right...", 'wp-upcoming-games' ); ?></p>
  127.             </div>
  128.         <?php wp_reset_postdata(); ?>
  129.         <?php endif ?>
  130.  
  131. <!-- ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement