123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?php
- function set_ai1ec_join($join, &$wp_query) {
- global $wpdb;
-
- $db_prefix=$wpdb->prefix;
- $join .=" 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;
-
- $db_prefix=$wpdb->prefix;
- if(! is_admin() && $wp_query->post_type ='ai3ec_event'){
- date_default_timezone_set("Europe/Rome");
-
- $where .= ' AND '. $db_prefix.'ai1ec_events.end >= \''.time().'\'';
-
- return $where;
- }
- }
- function set_ai1ec_limits( $limit, $query ) {
- return 'LIMIT 0, 5';
- }
- add_filter('posts_orderby', 'set_ai1ec_orderby');
- function set_ai1ec_orderby($orderby) {
- global $wpdb;
-
- $db_prefix=$wpdb->prefix;
- $orderby = $db_prefix."ai1ec_events.start ASC";
- return $orderby;
- }
- function get_ai1ec_box($attrs){ ?>
- <?php
- global $count2 ;
- $box_title = "Prossimi Eventi";
- if( !empty($attrs['title']) )
- $box_title = $attrs['title'];
- $Posts = 12;
- if( !empty($attrs['num']) )
- $Posts = $attrs['num'];
-
- $home_layout = '';
- if( !empty($attrs['layout']) )
- $home_layout = $attrs['layout'];
-
- $offset = '';
- if( !empty($attrs['offset']) )
- $home_layout = $attrs['offset'];
-
- $page_ids=Array();
- if( !empty($attrs['ids']) )
- $page_ids=explode(",",$attrs['ids']);
- $args=Array(
- 'post_type'=> 'ai1ec_event',
- 'no_found_rows' => 1,
- 'posts_per_page' => $Posts,
- 'offset'=> '',
- 'tax_query' => array(
- array(
- 'field' => 'id',
- 'terms' => $page_ids,
- 'taxonomy' => 'events_categories',
- )
- ),
- );
- 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 );
- //http://codex.wordpress.org/Class_Reference/WP_Query
- $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;
- ?>
- <?php if( $home_layout == '2c'): //************** 2C ****************************************************** ?>
- <?php $count2++; ?>
- <section class="cat-box column2 <?php if($count2 == 2) { echo 'last-column'; $count2=0; } ?>">
- <div class="cat-box-title">
- <h2><?php echo $box_title ; ?></h2>
- <div class="stripe-line"></div>
- </div><!-- post-thumbnail /-->
- <div class="cat-box-content">
-
- <?php if($cat_query->have_posts()): ?>
- <ul>
- <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
- <?php if($count == 1) : ?>
- <li <?php tie_post_class('first-news'); ?>>
- <div class="inner-content">
- <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
- <div class="post-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
- <?php tie_thumb( 'tie-medium' ); ?>
- <span class="overlay-icon"></span>
- </a>
- </div><!-- post-thumbnail /-->
- <?php endif; ?>
-
- <h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
-
- <div class="entry">
- <?php tie_excerpt_home() ?>
- <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a>
- </div>
- </div>
- </li><!-- .first-news -->
- <?php else: ?>
- <li <?php tie_post_class(); ?>>
- <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
- <div class="post-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
- </div><!-- post-thumbnail /-->
- <?php endif; ?>
- <h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
- <div class="entry">
- <?php tie_excerpt_home() ?>
- </div>
- </li>
- <?php endif; ?>
- <?php endwhile;?>
- </ul>
- <?php endif; ?>
- </div><!-- .cat-box-content /-->
- </section> <!-- Two Columns -->
-
-
- <?php elseif( $home_layout == '1c' ): //************** 1C ****************************************************** ?>
- <section class="cat-box wide-box">
- <div class="cat-box-title">
- <h2><?php echo $box_title ; ?></h2>
- <div class="stripe-line"></div>
- </div><!-- post-thumbnail /-->
- <div class="cat-box-content">
-
- <?php if($cat_query->have_posts()): ?>
- <ul>
- <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
- <?php if($count == 1) : ?>
- <li <?php tie_post_class( 'first-news' ); ?>>
- <div class="inner-content">
- <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
- <div class="post-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
- <?php tie_thumb( 'tie-large' ); ?>
- <span class="overlay-icon"></span>
- </a>
- </div><!-- post-thumbnail /-->
- <?php endif; ?>
-
- <h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <div class="entry">
- <?php tie_excerpt_home() ?>
- <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a>
- </div>
- </div>
- </li><!-- .first-news -->
- <?php else: ?>
- <li <?php tie_post_class(); ?>>
- <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
- <div class="post-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
- </div><!-- post-thumbnail /-->
- <?php endif; ?>
- <h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
- <div class="entry">
- <?php tie_excerpt_home() ?>
- </div>
- </li>
- <?php endif; ?>
- <?php endwhile;?>
- </ul>
- <div class="clear"></div>
- <?php endif; ?>
- </div><!-- .cat-box-content /-->
- </section><!-- Wide Box -->
- <?php else : //************** list ********************************************************************************** ?>
-
- <section class="cat-box list-box">
- <div class="cat-box-title">
- <h2><?php echo $box_title ; ?></h2>
- <div class="stripe-line"></div>
- </div><!-- post-thumbnail /-->
- <div class="cat-box-content">
-
- <?php if($cat_query->have_posts()): ?>
- <ul>
- <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
- <?php if($count == 1) : ?>
- <li <?php tie_post_class( 'first-news' ); ?>>
- <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
- <div class="post-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
- <?php tie_thumb( 'tie-medium' ); ?>
- <span class="overlay-icon"></span>
- </a>
- </div><!-- post-thumbnail /-->
- <?php endif; ?>
-
- <h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
-
- <div class="entry">
- <?php tie_excerpt_home() ?>
- <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a>
- </div>
- </li><!-- .first-news -->
- <?php else: ?>
- <li <?php tie_post_class( 'other-news' ); ?>>
- <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
- <div class="post-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
- </div><!-- post-thumbnail /-->
- <?php endif; ?>
- <h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
- <div class="entry">
- <?php tie_excerpt_home() ?>
- </div>
- </li>
- <?php endif; ?>
- <?php endwhile;?>
- </ul>
- <div class="clear"></div>
- <?php endif; ?>
- </div><!-- .cat-box-content /-->
- </section><!-- List Box -->
- <?php endif; ?>
- <?php } ?>
|