Unable to sort wp_query by date/time with multiple meta_key s

Just an idea: you could save your time values in an array and then sort it with PHP. Example: $keys = array(‘opening_time’, ‘film_time’, ‘artist_talk_time’); $times = array(); $custom_field_keys = get_post_custom_keys(); foreach ($custom_field_keys as $custom_field_key) { if (in_array($custom_field_key, $keys) { $custom_field_value = get_post_meta($post->ID, $custom_field_key, true); if ($custom_field_value >= $thedate && $custom_field_value <= $future) { $counttest++; $times[$custom_field_key] … Read more

WordPress & PHP sessions

It is relatively simple. I’ve giving you a few steps. User visits your site and hit ‘Add to basket’ on an event. You need to send this data to server (as you wanted to store in php session). you can submit a form (for simplicity) either in synchronously or asynchronously (ajax). You need to submit … Read more

How to use template field in the Event Organiser plugin widget

The template field allows you to enter what will appear on the event list widget. It accepts various place holders (you can see the documentation here – the template can be used for the [eo_events] shortcode too). One of the place-holders is %start{date-format}{time-format}% which outputs the start date/time of an event with the specified date … Read more

Checking if field is set before comparing with meta_query in query_posts?

I know how to do that in pure SQL but I can’t get WP_Query to nest conditions in the way required. If it is acceptable, the easiest way to make this work would be to assign an arbitrary far future end date when the data is saved to the database. Something like strtotime(“2038-01-01”). That is … Read more

Post Terms As Class Name For Full Calendar Events

You are using get_single_term in a way that would require it to return a value… $term = get_single_term($post->ID, ‘course_locations’); … but you have written it in such a way that it echos a value. You should have… function get_single_term($post_id, $taxonomy) { $terms = wp_get_object_terms($post_id, $taxonomy); if(!is_wp_error($terms)) { return $terms[0]->name; } } I noticed a couple … Read more

Identifying a Page Containing Shortcode at `init`

I’ve found an answer, although messy. /* // Plugin information goes here */ $GLOBALS[‘example_class’] = new example_class; class example_class { var $public_loaded = false, $content=””; public function admin_init() { add_menu_page( // … ); } // End of admin_init function public function get_random( ) { // … } } // End of example class add_action(‘init’, function() … Read more

Query Event Posts by Date

You need type casting for custom fields event-start-date and event-end-date. Then it will compare with time() & date() value. You need to add ‘type’ => ‘DATE’, in your meta query args. So your meta query will be like this: switch ($print_type) { case ‘current’: $meta_quer_args = array( ‘relation’ => ‘AND’, array( ‘key’ => ‘event-start-date’, ‘value’ … Read more