Hide based on date
-
I have a custom coded events post type where the page is working just fine with the exception of not hiding past events. I need the page to auto-hide events as the “start date” is passed
Here is the code for the page:
<?php get_header();?> <div class="page-container row-fluid"> <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <div class="breadcrumb"> <div class="container"> <a href="<?php echo home_url();?>">Home</a> » <a href="events">Events </a> <h1>Events</h1> </div> </div> <div class="container"> <div class="span8"> <?php $args= array( 'post_type' => 'events', 'posts_per_page' => -1, 'meta_key' => 'start_date', 'orderby' => 'meta_value_num', 'order' => 'ASC' ); $wp_query = new WP_Query($args); //if ( have_posts() ) : ?> <?php while($wp_query->have_posts()) : $wp_query->the_post();?> <div class="entry-content"> <div class="event-title"> <h2><a href="<?php the_permalink()?>"><?php the_title()?></a></h2> </div> <div class="meta"> <p><?php if(get_field('start_date')):?> <?php $date = get_field('start_date'); // $date = 19881123 (23/11/1988) // extract Y,M,D $y = substr($date, 0, 4); $m = substr($date, 4, 2); $d = substr($date, 6, 2); // create UNIX $time = strtotime("{$d}-{$m}-{$y}"); ?> <strong>Date:</strong> <?php echo date('m/d/Y', $time);// format date (11/23/1988)?> <?php endif; ?><?php if(get_field('locations')):?>| <strong>Location:</strong> <?php the_field('locations')?> <?php endif; ?></p> </div> <div class="clearfix"></div> <?php the_excerpt();?> <hr> </div> <?php endwhile; //wp_reset_query(); ?> <?php // pagination defaulttheme_content_nav( 'nav-below' ); ?> <?//php else : ?> <?//php get_template_part('not', 'found')?> <?//php endif; // end have_posts() check ?> </div> <div class="sidebar span4"> <?php if ( is_active_sidebar( 'buttons_sidebar' ) ) : ?> <?php dynamic_sidebar( 'buttons_sidebar' ); ?> <?php endif;?> <?php if ( is_active_sidebar( 'events_sidebar' ) ) : ?> <?php dynamic_sidebar( 'events_sidebar' ); ?> <?php endif;?> <?php if ( is_active_sidebar( 'general_sidebar' ) ) : ?> <?php dynamic_sidebar( 'general_sidebar' ); ?> <?php endif;?> </div> </div> </div> </div> <?php get_footer();?>
Can anyone help me figure out what I am doing wrong as I thought the page was already coded to hide an event when the start date passed.
Thanks,
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hide based on date’ is closed to new replies.