ok im working on a website using post type event with post_meta event_start_date, i created a shortcode and everything is displaying fine except for it displaying in order, it seems as its not displaying by using meta_key nor meta_value. this the page http://mixedbagnext.com/wordpress/events/ you'll notice the date order is wrong, i want it to display the most recent date first then the other dates following. side note im using more fields plugin to create post_meta and is set to date entered 2015-01-01. here is my code
// SHORTCODE event
function event_shortcode( $atts ) {
extract( shortcode_atts( array( 'limit' => -1, 'type' => 'event'), $atts ) );
$eventlist = '';
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$carousel_query = new WP_Query(array (
'posts_per_page' => $limit,
'post_type' => $type,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'meta_value_num',
'meta_key' => 'event_start_date',
'meta_query' => array(
// 'relation' => 'AND',
array(
'key' => 'event_start_date',
'value' => date('Y-m-d', strtotime('-6 hours')), //value of "order-date"
'compare' => '>=', //show events greater than or equal to today
'type' => 'CHAR'
)
),
'paged' => $paged ));
if ($carousel_query->have_posts()) :
$eventlist .= '<ul class="event-list clearfix">';
while ($carousel_query->have_posts()) : $carousel_query->the_post();
$event_artist = wp_strip_all_tags( get_the_term_list( get_the_ID(), 'artist_event', ' ', ' , ', ' ') );
$event_start_date = get_post_meta(get_the_ID(), 'event_start_date', true );
$fixed_date_day = strtotime($event_start_date);
$fixed_date_month = strtotime($event_start_date);
$event_start_time = get_post_meta(get_the_ID(), 'event_start_time', true );
$fixed_time_start = strtotime($event_start_time);
$event_end_date = get_post_meta(get_the_ID(), 'event_end_date', true );
$event_end_time = get_post_meta(get_the_ID(), 'event_end_time', true );
$fixed_time_end = strtotime($event_end_time);
$event_location = get_post_meta(get_the_ID(), 'event_location', true );
$event_address = get_post_meta(get_the_ID(), 'event_address', true );
$event_city = get_post_meta(get_the_ID(), 'event_city', true );
$event_state = get_post_meta(get_the_ID(), 'event_state', true );
$event_zipcode = get_post_meta(get_the_ID(), 'event_zipcode', true );
$event_telephone = get_post_meta(get_the_ID(), 'event_telephone', true );
$event_website = get_post_meta(get_the_ID(), 'event_website', true );
$event_description = get_post_meta(get_the_ID(), 'event_description', true );
$event_url = get_post_meta(get_the_ID(), 'event_url', true );
$event_button = get_post_meta(get_the_ID(), 'event_button', true );
$event_btn_img = get_post_meta(get_the_ID(), 'event_btn_img', true );
$event_price = get_post_meta(get_the_ID(), 'event_price', true );
$eventlist .= '<li id="event-list-'. get_the_ID() .'" class="' . implode(' ', get_post_class('clearfix')) . '" >'
.'<div class="event-list-date">'
.'<span class="event-list-day">'.date('d' , $fixed_date_day) .'</span>'
.'<span class="event-list-month">'.date('M' , $fixed_date_month) .'</span>'
.'</div>'
.'<div class="event-list-title">' . get_the_title() . '</div>'
.'<div class="event-list-time"><span class="yellow-text">time:</span>'.date('g:i A' , $fixed_time_start) .'</div>'
.'<div class="event-list-artist"><span class="yellow-text">with:</span>'.$event_artist.'</div>'
.'<div class="event-list-location"><span class="yellow-text">location:</span>'.$event_city.', '.$event_state.'</div>'
.'<div class="event-list-link"><a href="'.$event_url.'" target="_blank">more info</a></div>'
.'</li>';
endwhile;
$eventlist .= '</ul>';
endif;
wp_reset_query();
return $eventlist;
}
add_shortcode( 'event', 'event_shortcode' );
// the shortcode -> [event limit="5"]