Corretto il bug sul limite dei post nel box, visualizzazione della data e dell'orari dell'evento, visualizzazione solo dei post con id N
This commit is contained in:
parent
2d7b17bbe5
commit
23ae8095b0
1 changed files with 24 additions and 13 deletions
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
function set_ai1ec_join($join, &$wp_query) {
|
function set_ai1ec_join($join, &$wp_query) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$db_prefix=$wpdb->prefix;
|
$db_prefix=$wpdb->prefix;
|
||||||
$join .=" LEFT JOIN ".$db_prefix."ai1ec_events
|
$join .=" JOIN ".$db_prefix."ai1ec_events
|
||||||
ON $wpdb->posts.ID = ".$db_prefix."ai1ec_events.post_id";
|
ON $wpdb->posts.ID = ".$db_prefix."ai1ec_events.post_id";
|
||||||
|
|
||||||
return $join;
|
return $join;
|
||||||
|
@ -11,25 +11,19 @@ function set_ai1ec_join($join, &$wp_query) {
|
||||||
|
|
||||||
function set_ai1ec_where( $where, &$wp_query ){
|
function set_ai1ec_where( $where, &$wp_query ){
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
$db_prefix=$wpdb->prefix;
|
||||||
if(! is_admin() && $wp_query->post_type ='ai3ec_event'){
|
if(! is_admin() && $wp_query->post_type ='ai3ec_event'){
|
||||||
date_default_timezone_set("Europe/Rome");
|
date_default_timezone_set("Europe/Rome");
|
||||||
$now=time();
|
|
||||||
|
|
||||||
$where .= ' AND (' . $wpdb->ai1ec_events.start .' >= \''.$now.'\' '.
|
$where .= ' AND '. $db_prefix.'ai1ec_events.end >= \''.time().'\'';
|
||||||
'OR ' . $wpdb->ai1ec_events.end .' >= \''.$now.'\' )';
|
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_ai1ec_limits( $limit, $query ) {
|
function set_ai1ec_limits( $limit, $query ) {
|
||||||
|
return 'LIMIT 0, 5';
|
||||||
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
|
|
||||||
return 'LIMIT 0, 6';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $limit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('posts_orderby', 'set_ai1ec_orderby');
|
add_filter('posts_orderby', 'set_ai1ec_orderby');
|
||||||
|
@ -58,12 +52,20 @@ function get_ai1ec_box($attrs){ ?>
|
||||||
'no_found_rows' => 1,
|
'no_found_rows' => 1,
|
||||||
'posts_per_page' =>$Posts,
|
'posts_per_page' =>$Posts,
|
||||||
'offset'=> '',
|
'offset'=> '',
|
||||||
|
'tax_query' => array(
|
||||||
|
array(
|
||||||
|
'field' => 'id',
|
||||||
|
'terms' => array(34),
|
||||||
|
'taxonomy' => 'events_categories',
|
||||||
|
)
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
add_filter('posts_join', 'set_ai1ec_join',10,2);
|
add_filter('posts_join', 'set_ai1ec_join',10,2);
|
||||||
add_filter( 'posts_where', 'set_ai1ec_where', 10, 2 );
|
add_filter( 'posts_where', 'set_ai1ec_where', 10, 2 );
|
||||||
add_filter('posts_orderby', 'set_ai1ec_orderby');
|
add_filter('posts_orderby', 'set_ai1ec_orderby');
|
||||||
add_filter( 'post_limits', 'set_ai1ec_limits', 10, 2 );
|
add_filter( 'post_limits', 'set_ai1ec_limits', 10, 2 );
|
||||||
|
//http://codex.wordpress.org/Class_Reference/WP_Query
|
||||||
$cat_query = new WP_Query($args);
|
$cat_query = new WP_Query($args);
|
||||||
remove_filter('posts_join', 'set_ai1ec_join');
|
remove_filter('posts_join', 'set_ai1ec_join');
|
||||||
remove_filter( 'posts_where', 'set_ai1ec_where');
|
remove_filter( 'posts_where', 'set_ai1ec_where');
|
||||||
|
@ -111,6 +113,9 @@ function get_ai1ec_box($attrs){ ?>
|
||||||
</div><!-- post-thumbnail /-->
|
</div><!-- post-thumbnail /-->
|
||||||
<?php endif; ?>
|
<?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>
|
<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>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endwhile;?>
|
<?php endwhile;?>
|
||||||
|
@ -159,6 +164,9 @@ function get_ai1ec_box($attrs){ ?>
|
||||||
</div><!-- post-thumbnail /-->
|
</div><!-- post-thumbnail /-->
|
||||||
<?php endif; ?>
|
<?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>
|
<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>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endwhile;?>
|
<?php endwhile;?>
|
||||||
|
@ -207,6 +215,9 @@ function get_ai1ec_box($attrs){ ?>
|
||||||
</div><!-- post-thumbnail /-->
|
</div><!-- post-thumbnail /-->
|
||||||
<?php endif; ?>
|
<?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>
|
<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>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endwhile;?>
|
<?php endwhile;?>
|
||||||
|
|
Loading…
Reference in a new issue