prefix; $join .=" LEFT JOIN ".$db_prefix."ai1ec_events ON $wpdb->posts.ID = ".$db_prefix."ai1ec_events.post_id"; return $join; } function set_ai1ec_where( $where, &$wp_query ){ global $wpdb; if(! is_admin() && $wp_query->post_type ='ai3ec_event'){ date_default_timezone_set("Europe/Rome"); $now=time(); $where .= ' AND (' . $wpdb->ai1ec_events.start .' >= \''.$now.'\' '. 'OR ' . $wpdb->ai1ec_events.end .' >= \''.$now.'\' )'; return $where; } } function set_ai1ec_limits( $limit, $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { return 'LIMIT 0, 6'; } return $limit; } add_filter('posts_orderby', 'set_ai1ec_orderby'); function set_ai1ec_orderby($orderby) { $orderby = $wpdb->ai1ec_events.start." ASC"; return $orderby; } function get_ai1ec_box($attrs){ ?> 'ai1ec_event', 'no_found_rows' => 1, 'posts_per_page' =>$Posts, 'offset'=> '', ); add_filter('posts_join', 'set_ai1ec_join',10,2); add_filter( 'posts_where', 'set_ai1ec_where', 10, 2 ); add_filter('posts_orderby', 'set_ai1ec_orderby'); add_filter( 'post_limits', 'set_ai1ec_limits', 10, 2 ); $cat_query = new WP_Query($args); remove_filter('posts_join', 'set_ai1ec_join'); remove_filter( 'posts_where', 'set_ai1ec_where'); remove_filter('posts_orderby', 'set_ai1ec_orderby'); remove_filter( 'post_limits', 'set_ai1ec_limits'); $count = 0; ?>

have_posts()): ?>

have_posts()): ?>

have_posts()): ?>