Advertisement
darrenbachan

content-upcoming-games.php

Jun 12th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.10 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 : 12;
  6.  
  7. $args = array(
  8.         'post_type'                 => 'upcoming-games',
  9.         'post_status'               => 'publish',
  10.         'orderby'                   => 'meta_value',
  11.         'meta_key'                  => 'release_date',
  12.         'meta_value'                => $time,
  13.         'meta_compare'              => '>=',
  14.         'order'                     => 'ASC',
  15.         'posts_per_page'                => $cpt_posts_per_page
  16.     );
  17.  
  18.     $upcoming_games = new WP_Query( $args );
  19.  
  20.     ?>
  21.    
  22.         <div class="col-md-12">
  23.             <div class="page-header see-more-header">
  24.                 <h3><?php _e('Upcoming Games', 'content-upcoming-games'); ?></h3>
  25.                 <?php if ( is_front_page() ) { ?>
  26.                     <a href="/upcoming-games/" class="">See All <i class="fa fa-long-arrow-right"></i></a>
  27.                 <?php }
  28.                 ?>
  29.             </div>
  30.         </div>
  31.            
  32.         <?php if ( $upcoming_games->have_posts() ) : ?>
  33.             <div class="col-md-12">
  34.                 <p><?php _e( "Check out some of the games that are coming out in <?php echo Date('Y'); ?>.", 'content-upcoming-games' ); ?></p>
  35.             </div>
  36.            
  37.             <article id="upcoming-games-list">
  38.                 <?php while ( $upcoming_games->have_posts() ) : $upcoming_games->the_post(); ?>
  39.                    
  40.                     <div id="<?php the_id(); ?>" class="col-xs-12 col-sm-6 <?php if(is_front_page()) { echo 'col-md-3'; } else { echo 'col-md-3'; } ?> upcoming-game">
  41.                         <?php $box_art = get_field('box_art'); ?>
  42.                         <div class="post-img">
  43.                             <a href="<?php the_permalink(); ?>"><img src="<?php echo $box_art; ?>" alt=""></a>
  44.                         </div>
  45.  
  46.                         <?php
  47.                             $release_date = get_field( "release_date");
  48.  
  49.                             $publisher = get_field( "publisher" );
  50.                             $developer = get_field( "developer" );
  51.                             $youtube_link = get_field( "youtube_link" );
  52.  
  53.                             $label_release_date = get_field_object($release_date);
  54.                         ?>
  55.                        
  56.                         <div class="upcoming-games-meta">
  57.                             <div class="meta-game-title">
  58.                                 <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
  59.                             </div>
  60.                            
  61.                             <ul>
  62.                                 <?php if( !empty ($release_date) ) echo '<li>' . '<span>' . 'Release Date' . ': ' . '</span>' . $release_date . '</li>'; ?>
  63.                                 <?php if( !empty ($publisher) ) echo '<li>' , '<span>', 'Publisher: ' , '</span>' , the_field('publisher') , '</li>'; ?>
  64.                                 <?php if( !empty ($developer) ) echo '<li>' , '<span>', 'Developer: ' , '</span>' , the_field("developer") , '</li>'; ?>
  65.                                 <?php
  66.                                 $genres = wp_get_object_terms( $post->ID,  'genres' );
  67.                                 $separator = ", ";
  68.                                 $output = '';
  69.  
  70.                                 if ( ! empty( $genres ) ) {
  71.                                     if ( ! is_wp_error( $genres ) ) {
  72.                                         echo '<li><span>Genre:</span> ';
  73.                                             foreach( $genres as $term ) {
  74.                                                 $output .= esc_html( $term->name ) . $separator;
  75.                                             } echo trim($output, $separator);
  76.                                         echo '</li>';
  77.                                     }
  78.                                 }
  79.                                 ?>
  80.                                 <?php
  81.                                 $consoles = wp_get_object_terms( $post->ID,  'consoles' );
  82.                                 $separator = ", ";
  83.                                 $output = '';
  84.  
  85.                                 if ( ! empty( $consoles ) ) {
  86.                                     if ( ! is_wp_error( $consoles ) ) {
  87.                                         echo '<li><span>Platforms:</span> ';
  88.                                             foreach( $consoles as $term ) {
  89.                                                 $output .= esc_html( $term->name ) . $separator;
  90.                                             } echo trim($output, $separator);
  91.                                         echo '</li>';
  92.                                     }
  93.                                 }
  94.                                 ?>
  95.                             </ul>
  96.  
  97.                             <div class="meta-comment-counter">
  98.                                 <a href="<?php the_permalink(); ?>#comments"><i class="fa fa-comments"></i> <?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?></a>
  99.                             </div>
  100.                            
  101.                             <?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>'; ?>
  102.                         </div><!--end upcoming games meta text-->
  103.                     </div><!-- end upcoming game -->
  104.                 <?php endwhile; ?>
  105.             </article><!-- end upcoming games -->
  106.         <?php else : ?>
  107.             <div class="col-md-12">
  108.                 <p><?php _e( "No Upcoming Games? Well this isn't right...", 'wp-upcoming-games' ); ?></p>
  109.             </div>
  110.         <?php wp_reset_postdata(); ?>
  111.         <?php endif ?>
  112.  
  113. <!-- ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement