Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $today = getdate();
- if (array_key_exists("sortby", $_GET) === true)
- {
- $newQuery = sortIt($_GET['sortby']);
- } elseif(array_key_exists('date', $_GET)) {
- $newQuery = new WP_Query(
- array(
- 'meta_key' => 'details_start_date',
- 'orderby' => 'meta_value',
- 'order'=> 'ASC',
- 'cat' => '5',
- 'posts_per_page' => '5',
- 'post_status'=>'future',
- 'paged'=>$paged,
- 'meta_query' => array(
- array(
- 'key' => 'details_start_date',
- 'value' => $_GET['date'],
- 'compare' => '=',
- )
- ),
- )
- );
- }
- else{
- $newQuery = new WP_Query(
- array(
- 'meta_key' => 'details_start_date',
- 'orderby' => 'meta_value',
- 'order'=> 'ASC',
- 'cat' => '5',
- 'posts_per_page' => '5',
- 'paged'=>$paged,
- 'post_status'=>'future',
- 'meta_query' => array(
- array(
- 'key' => 'details_start_date',
- 'value' => date('Y-m-d'),
- 'compare' => '>=',
- )
- ),
- )
- );
- $btnall = "";
- $btnupcoming = "btn-upcoming";
- $btnpast = "";
- }
- function sortIt($sortType)
- {
- global $wp_query;
- global $btnall;
- global $btnupcoming;
- global $btnpast;
- $cat_ID = get_query_var('cat');
- if (strcmp($sortType, 'past') == 0 )
- {
- $newQuery = new WP_Query(
- array(
- 'meta_key' => 'details_start_date',
- 'orderby' => 'meta_value',
- 'order'=> 'DESC',
- 'cat' => '5',
- 'posts_per_page' => '5',
- 'post_status'=>'publish',
- 'paged'=>$paged,
- 'meta_query' => array(
- array(
- 'key' => 'details_start_date',
- 'value' => date('Y-m-d'),
- 'compare' => '<',
- )
- ),
- )
- );
- $btnall = "";
- $btnupcoming = "";
- $btnpast = "btn-past";
- }
- if (strcmp($sortType, 'upcoming') == 0 )
- {
- $newQuery = new WP_Query(
- array(
- 'meta_key' => 'details_start_date',
- 'orderby' => 'meta_value',
- 'order'=> 'ASC',
- 'cat' => '5',
- 'posts_per_page' => '5',
- 'post_status'=>'future',
- 'paged'=>$paged,
- 'meta_query' => array(
- array(
- 'key' => 'details_start_date',
- 'value' => date('Y-m-d'),
- 'compare' => '>=',
- )
- ),
- )
- );
- $btnall = "";
- $btnupcoming = "btn-upcoming";
- $btnpast = "";
- }
- return $newQuery;
- }
- ?>
- <?php get_header(); ?>
- <div id="content" class="clearfix row-fluid">
- <div id="main" class="span12 clearfix" role="main">
- <div class="main-content">
- <div class="content-banner">
- <img src="<?php echo get_template_directory_uri();?>/images/events-banner.jpg" alt="" />
- </div>
- <div class="clearfix row-fluid">
- <div class="clearfix span8">
- <?php wp_reset_postdata(); ?>
- <div class="btn-group">
- <a class="btn btn-default <?=$btnupcoming?>" href="<?php echo home_url(); ?>/events?sortby=upcoming" role="button">Upcoming</a>
- <a class="btn btn-default <?=$btnpast?>" href="<?php echo home_url(); ?>/events?sortby=past" role="button">Past</a>
- </div>
- <br /><br />
- <?php if(array_key_exists('date', $_GET)):?>
- <h2>Events on <?php echo date('F d, Y', strtotime($_GET['date'])) ?></h2>
- <br/><br/>
- <?php endif;?>
- <?php $the_query = $newQuery; ?>
- <?php if ($the_query->have_posts()): ?>
- <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
- <?php
- $custom = get_post_custom();
- $custom_date = date('F d, Y', strtotime($custom['details_start_date'][0]));
- ?>
- <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
- <header>
- <h3 style="margin:0;line-height:35px;"><a style="color:#1e4667;" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?> </a></h3>
- <time datetime="<?php echo $custom_date; ?>" pubdate><?php echo $custom_date; ?>
- <?php if(!empty($custom['details_start_time'][0])):?>
- | <?php echo $custom['details_start_time'][0] ?>
- <?php endif;?>
- </time>
- </header> <!-- end article header -->
- <section class="post_content clearfix">
- <?php the_excerpt( __("Read more »","bonestheme") ); ?>
- </section> <!-- end article section -->
- </article> <!-- end article -->
- <?php endwhile; ?>
- <?php else:?>
- <h4>Events could not be found...</h4>
- <?php endif;?>
- <?php
- $big = 999999999; // need an unlikely integer
- echo paginate_links( array(
- 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
- 'format' => '?paged=%#%',
- 'current' => max( 1, get_query_var('paged') ),
- 'total' => $the_query->max_num_pages
- ) );
- ?>
- <?php if (function_exists('page_navi')) { // if expirimental feature is active ?>
- <?php page_navi(); // use the page navi function ?>
- <?php } else { // if it is disabled, display regular wp prev & next links ?>
- <nav class="wp-prev-next">
- <ul class="clearfix">
- <li class="prev-link"><?php next_posts_link(_e('« Older Entries', "bonestheme")) ?></li>
- <li class="next-link"><?php previous_posts_link(_e('Newer Entries »', "bonestheme")) ?></li>
- </ul>
- </nav>
- <?php } ?>
- </div>
- <?php get_sidebar('events'); ?>
- </div>
- </div>
- </div> <!-- end #main -->
- </div> <!-- end #content -->
- </div> <!-- end #container -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement