Home Forums General Issues Displaying posts by date picker, and hiding expired. Reply To: CPT pagination chaining, displaying posts by date picker.

  • I found a simple script which allowed me to show upcoming events.

    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $the_query = new WP_Query( array(
    	'post_type' => 'events',
    	'posts_per_page' => 4,
    	'order' => 'ASC',
    	'orderby' => 'meta_value',
    	'meta_key' => 'start_date',
    	'paged' => $paged
    ) );
    $current_header = '';
    while ( $the_query->have_posts() ) :
    # get the datum for this post
    $temp_date = get_post_meta( get_the_ID(), 'start_date', true );
    if (strtotime($temp_date) > strtotime('now')){
    	if ( $temp_date != $current_header  ) {
    	$current_header = $temp_date;
    	include 'item-archive.php';
    <?php } endwhile;?>

    I also removed the pagination chaining because I couldn’t get it to work with this code.

    I have one tester event that has expired, just to ensure its not showing expired events. I have it set to 4 post per page for testing, however on page 1 it only shows 3 posts, like the hidden event is still being counted.

    I’ve been searching for a good solution for this all day, however I can’t find anything that will make it work.