Problem with sorting posts with meta field date (1 post)

  1. Aboobacker P
    Posted 2 years ago #

    I am so tired with trying this and I am still stuck with the problem.
    I have a post type named uspa_events with a custom meta field ab_event_date to set the event date.

    What I want is I want to display only the upcoming events in a sorted order. I can display the upcoming events based on comparing the event date meta with today's date.

    But they are not in a sorted order! please refer the scrolling show under under Events in http://growpolo.com.


    	if( get_option(PREFIX.'no_of_events') != 0 ) {
    		$EvntCount = get_option(PREFIX.'no_of_events');
    	else { $EvntCount = 5; }
    	$i = 1;
    		$today = strtotime(date("Y-m-d"));
    		$event_date = strtotime(get_post_meta($post->ID, 'ab_event_date', true)); 
    		if ($event_date >= $today) { ?>
    			<?php if( $i <= $EvntCount ) { ?>
    					<?php if( has_post_thumbnail() ) { the_post_thumbnail('event_img'); }
    					else { ?>
    						<img src="<?php echo IMG; ?>/img14.jpg" width="964" height="316" alt="image" />
    					<?php } ?>
    					<div class="description">
    						<em class="line"> </em>
    						<div class="holder">
    							<em class="date"><?php echo date("M d",$event_date); ?></em>
    							<strong class="title"><?php the_title();?></strong>
    							<div class="row"><?php the_content(); ?></div>
    	   <?php $i++; } } ?>
    <?php endwhile; wp_reset_query(); ?>

    Please help.

    Advance Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic