Support

Account

Forum Replies Created

  • Hi Elliot,

    Thank you very much for the reply.

    Before I noticed this I was still working on this problem, and got the following to work:

    <?php
    $currentdate = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")));
    
    $wp_query = new WP_Query(  array (
        'post_type' => 'events',
        'meta_query'=> array(
            array(
              'key' => 'start_date',
              'compare' => '>',
              'value' => $currentdate,
              'type' => 'DATE',
            )),
        'meta_key' => 'start_date',
        'orderby' => 'meta_value',
        'order' => 'ASC',
    	'posts_per_page' => 12,
    	'paged' => $paged,
        )
    ); ?>

    Its not counting the expired posts and is paging perfectly too.

    Thanks again for the reply,
    Darren.

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

    <?php
    
    $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() ) :
    $the_query->the_post();
    
    # 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.

Viewing 2 posts - 1 through 2 (of 2 total)