Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $time = current_time( 'timestamp' ); // Get current unix timestamp
- $cpt_posts_per_page = ( is_front_page() ) ? 4 : -1;
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $args = array(
- 'post_type' => 'upcoming-games',
- 'post_status' => 'publish',
- 'orderby' => 'meta_value',
- 'meta_key' => 'release_date',
- 'meta_value' => $time,
- 'meta_compare' => '>=',
- 'order' => 'ASC',
- 'posts_per_page' => $cpt_posts_per_page,
- 'paged' => $paged
- );
- $upcoming_games = new WP_Query( $args );
- ?>
- <div class="col-md-12">
- <div class="page-header see-more-header">
- <h3><?php _e('Upcoming Games', 'content-upcoming-games'); ?></h3>
- <?php if ( is_front_page() ) { ?>
- <a href="/upcoming-games/" class="">See All <i class="fa fa-long-arrow-right"></i></a>
- <?php }
- ?>
- </div>
- </div>
- <?php if ( $upcoming_games->have_posts() ) : ?>
- <div class="col-md-12">
- <p>Check out some of the games that are coming out in <?php echo Date('Y'); ?>.</p>
- </div>
- <div class="controls col-md-12">
- <label>Sort By:</label>
- <button class="filter" data-filter="all">All</button>
- <button class="filter" data-filter=".ps4">PS4</button>
- <button class="filter" data-filter=".xbox-one">Xbox One</button>
- <button class="filter" data-filter=".wii-u">Wii U</button>
- <button class="filter" data-filter=".pc">PC</button>
- </div>
- <div id="upcoming-games-list" class="col-md-12">
- <?php while ( $upcoming_games->have_posts() ) : $upcoming_games->the_post(); ?>
- <?php
- $class ='';
- foreach ($consoles as $console) {
- $class .= $console->slug . ' ';
- }
- ?>
- <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">
- <?php $box_art = get_field('box_art'); ?>
- <div class="post-img">
- <a href="<?php the_permalink(); ?>"><img src="<?php echo $box_art; ?>" alt=""></a>
- </div>
- <?php
- $release_date = get_field( "release_date");
- $publisher = get_field( "publisher" );
- $developer = get_field( "developer" );
- $youtube_link = get_field( "youtube_link" );
- $label_release_date = get_field_object($release_date);
- ?>
- <div class="upcoming-games-meta">
- <div class="meta-game-title">
- <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
- </div>
- <ul>
- <?php if( !empty ($release_date) ) echo '<li>' . '<span>' . 'Release Date' . ': ' . '</span>' . $release_date . '</li>'; ?>
- <?php if( !empty ($publisher) ) echo '<li>' , '<span>', 'Publisher: ' , '</span>' , the_field('publisher') , '</li>'; ?>
- <?php if( !empty ($developer) ) echo '<li>' , '<span>', 'Developer: ' , '</span>' , the_field("developer") , '</li>'; ?>
- <?php
- $genres = wp_get_object_terms( $post->ID, 'genres' );
- $separator = ", ";
- $output = '';
- if ( ! empty( $genres ) ) {
- if ( ! is_wp_error( $genres ) ) {
- echo '<li><span>Genre:</span> ';
- foreach( $genres as $term ) {
- $output .= esc_html( $term->name ) . $separator;
- } echo trim($output, $separator);
- echo '</li>';
- }
- }
- ?>
- <?php
- $consoles = wp_get_object_terms( $post->ID, 'consoles' );
- $separator = ", ";
- $output = '';
- if ( ! empty( $consoles ) ) {
- if ( ! is_wp_error( $consoles ) ) {
- echo '<li><span>Platforms:</span> ';
- foreach( $consoles as $term ) {
- $output .= esc_html( $term->name ) . $separator;
- } echo trim($output, $separator);
- echo '</li>';
- }
- }
- ?>
- </ul>
- <div class="meta-comment-counter">
- <a href="<?php the_permalink(); ?>#comments"><i class="fa fa-comments"></i> <?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?></a>
- </div>
- <?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>'; ?>
- </div><!--end upcoming games meta text-->
- </div><!-- end upcoming game -->
- <?php endwhile; ?>
- </div><!-- end upcoming games -->
- <?php else : ?>
- <div class="col-md-12">
- <p><?php _e( "No Upcoming Games? Well this isn't right...", 'wp-upcoming-games' ); ?></p>
- </div>
- <?php wp_reset_postdata(); ?>
- <?php endif ?>
- <!-- ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement