Advertisement
darrenbachan

Untitled

Jun 8th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.68 KB | None | 0 0
  1. <?php
  2.  
  3. $today = date('F j, Y');
  4.  
  5. $args = array(
  6.         'post_type'                 => 'upcoming-games',
  7.         // 'orderby'                    => 'menu_order',
  8.         'order'                     => 'ASC',
  9.         // 'no_found_rows'              => true,
  10.         //'update_post_term_cache'  => false, // no taxonomy data
  11.         'posts_per_page'                => 4,
  12.         // 'meta_query' => array(
  13.         //  array(
  14.         //         'key'        => 'end_date',
  15.         //         'compare'    => '>=',
  16.         //         'value'      => $today,
  17.         //     ),
  18.         //      array(
  19.         //         'key'        => 'start_date',
  20.         //         'compare'    => '<=',
  21.         //         'value'      => $today,
  22.         //     ))
  23.     );
  24.  
  25.     $upcoming_games = new WP_Query( $args );
  26.  
  27.     ?>
  28.    
  29.         <div class="col-md-12">
  30.             <div class="page-header">
  31.                 <h3><?php _e('Upcoming Games', 'wp-upcoming-games'); ?></h3>
  32.             </div>
  33.         </div>
  34.            
  35.         <?php if ( $upcoming_games->have_posts() ) : ?>
  36.             <div class="col-md-12">
  37.                 <p><?php _e( "Check out some of the games that are coming out soon!", 'wp-upcoming-games' ); ?></p>
  38.             </div>
  39.            
  40.             <article id="upcoming-games-list">
  41.                 <?php while ( $upcoming_games->have_posts() ) : $upcoming_games->the_post(); ?>
  42.                    
  43.                     <div id="<?php the_id(); ?>" class="col-xs-12 col-sm-4 col-md-3 upcoming-game">
  44.                         <?php if(has_post_thumbnail()) : ?>
  45.                             <div class="post-img">
  46.                                     <?php the_post_thumbnail(); ?>
  47.                             </div>
  48.                         <?php endif; ?>
  49.  
  50.                         <?php
  51.                             $release_date = get_field( "release_date");
  52.  
  53.                             $publisher = get_field( "publisher" );
  54.                             $developer = get_field( "developer" );
  55.                             $youtube_link = get_field( "youtube_link" );
  56.  
  57.                             $label_release_date = get_field_object($release_date);
  58.                         ?>
  59.                        
  60.                         <div class="upcoming-games-meta">
  61.                             <div class="meta-game-title">
  62.                                 <h4><?php the_title(); ?></h4>
  63.                             </div>
  64.                            
  65.                             <ul>
  66.                                 <?php if( !empty ($release_date) ) echo '<li>' . '<span>' . 'Release Date' . ': ' . '</span>' . $release_date . '</li>'; ?>
  67.                                 <?php if( !empty ($publisher) ) echo '<li>' , '<span>', 'Publisher: ' , '</span>' , the_field('publisher') , '</li>'; ?>
  68.                                 <?php if( !empty ($developer) ) echo '<li>' , '<span>', 'Developer: ' , '</span>' , the_field("developer") , '</li>'; ?>
  69.                                 <?php
  70.                                 $genres = wp_get_object_terms( $post->ID,  'genres' );
  71.                                 $separator = ", ";
  72.                                 $output = '';
  73.  
  74.                                 if ( ! empty( $genres ) ) {
  75.                                     if ( ! is_wp_error( $genres ) ) {
  76.                                         echo '<li><span>Genre:</span> ';
  77.                                             foreach( $genres as $term ) {
  78.                                                 $output .= esc_html( $term->name ) . $separator;
  79.                                             } echo trim($output, $separator);
  80.                                         echo '</li>';
  81.                                     }
  82.                                 }
  83.                                 ?>
  84.                                 <?php
  85.                                 $consoles = wp_get_object_terms( $post->ID,  'consoles' );
  86.                                 $separator = ", ";
  87.                                 $output = '';
  88.  
  89.                                 if ( ! empty( $consoles ) ) {
  90.                                     if ( ! is_wp_error( $consoles ) ) {
  91.                                         echo '<li><span>Platforms:</span> ';
  92.                                             foreach( $consoles as $term ) {
  93.                                                 $output .= esc_html( $term->name ) . $separator;
  94.                                             } echo trim($output, $separator);
  95.                                         echo '</li>';
  96.                                     }
  97.                                 }
  98.                                 ?>
  99.                             </ul>
  100.                             <?php if( !empty ($youtube_link) ) echo '<div class="meta-trailer">' . '<a class="btn btn-secondary btn-md" href="'. $youtube_link .'" target="_blank">' . 'Watch Trailer' . '</a>' . '</div>'; ?>
  101.                         </div><!--end upcoming games meta text-->
  102.                     </div><!-- end upcoming game -->
  103.                 <?php endwhile; ?>
  104.             </article><!-- end upcoming games -->
  105.         <?php else : ?>
  106.             <div class="col-md-12">
  107.                 <p><?php _e( "No Upcoming Games? Well this isn't right...", 'wp-upcoming-games' ); ?></p>
  108.             </div>
  109.         <?php endif ?>
  110.  
  111. <!-- ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement