john2016 on "order by meta_value where value contains array with date"

ساخت وبلاگ

Hi,

I'm having trouble to sort events by startdate.

I have events with a ticket system plugin event tickets plus, every ticket has a date. I'm displaying the events 0,10 per genre and the order has to be by first ticket date after todays date.

The events are in the wp_posts table, the tickets are in the wp_postmeta table:

meta_id => #,
post_id => #,
meta_key => 'movie_time_values',
meta_value = > ',{"theatre":"","<strong>date</strong>":"<em>05.28.2016</em>","time":"20:00","place":"","ticket":"","button_text":"","button_link":""}'

Right now I'm stuck with the following, it gives no result:

global $query_string; $today = current_time('m.d.Y'); $args = array( 'numberposts' => -1, 'post_type' => 'movies', 'event_categories' => '', 'posts_per_page' => -1, 'meta_key' => 'movie_time_values', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'movie_time_values', 'value' => $today, 'compare' => '>=' ) ) ); $args = array_merge( $args , array_filter( $wp_query->query_vars ) ); query_posts( $args ); /* Start the Loop */ while ( have_posts() ) { the_post();
.......

There is a result when i delete the following in above code:

'meta_key' => 'movie_time_values',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'AND', array( 'key' => 'movie_time_values', 'value' => $today, 'compare' => '>='
))

And this gives the following query:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) JOIN wp_icl_translations t ON wp_posts.ID = t.element_id AND t.element_type = CONCAT('post_', wp_posts.post_type) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (31) AND tt1.term_taxonomy_id IN (31)
) AND wp_posts.post_type = 'movies' AND (wp_posts.post_status = 'publish') AND ( ( t.language_code = 'nl' AND wp_posts.post_type IN ('post','page','attachment','ticket-meta-fieldset','tribe_rsvp_tickets','mc4wp-form','movies','special_offers','tribe_wooticket' ) ) OR wp_posts.post_type NOT IN ('post','page','attachment','ticket-meta-fieldset','tribe_rsvp_tickets','mc4wp-form','movies','special_offers','tribe_wooticket' ) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10

Thanks in advance

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 187 تاريخ : دوشنبه 27 ارديبهشت 1395 ساعت: 15:04