prefix; $join .=" JOIN ".$db_prefix."ai1ec_events ON $wpdb->posts.ID = ".$db_prefix."ai1ec_events.post_id"; return $join; } function set_ai1ecrss_where( $where, &$wp_query ){ global $wpdb; $db_prefix=$wpdb->prefix; if(! is_admin() && $wp_query->post_type ='ai3ec_event'){ date_default_timezone_set("Europe/Rome"); $start = time()+ (7 * 24 * 60 * 60); $end = time(); //$where .= ' AND '. $db_prefix.'ai1ec_events.start <= \''.$start.'\'' .' AND '. $db_prefix.'ai1ec_events.end >= \''.$end.'\''; $where .= ' AND '. $db_prefix.'ai1ec_events.start <= \''.$start.'\''; return $where; } } function set_ai1ecrss_orderby($orderby) { global $wpdb; $db_prefix=$wpdb->prefix; $orderby = $db_prefix."ai1ec_events.start DESC"; return $orderby; } function getEvent($cat){ $args=Array( 'post_type'=> 'ai1ec_event', 'no_found_rows' => 1, 'showposts' => 10 ); if($cat != "all" ) { $args['tax_query'] = array( Array( 'taxonomy' => 'events_categories', 'field' => 'slug', 'terms' => Array($cat), ) ); } //var_dump($args); add_filter( 'posts_join', 'set_ai1ecrss_join',10,2 ); add_filter( 'posts_where', 'set_ai1ecrss_where', 10, 2 ); add_filter( 'posts_orderby', 'set_ai1ecrss_orderby' ); //http://codex.wordpress.org/Class_Reference/WP_Query $cat_query = new WP_Query($args); remove_filter( 'posts_join', 'set_ai1ecrss_join' ); remove_filter( 'posts_where', 'set_ai1ecrss_where' ); remove_filter( 'posts_orderby', 'set_ai1ecrss_orderby' ); header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true); echo ''; ?> <?php bloginfo_rss('name'); ?> - Events Feed have_posts()): ?> have_posts()) : $cat_query->the_post(); ?> <?php the_title_rss(); ?> ]]> ]]> ciaoget( 'ai1ecrss' ); if ( ! $category) return; getEvent($category); die; } add_action( 'template_redirect', 'wds_ai1ec_rss_restapi_endpoint_call' );