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:
gine 2014-11-03 18:21:54 +01:00
parent 2d7b17bbe5
commit 23ae8095b0

View file

@ -1,9 +1,9 @@
<?php
function set_ai1ec_join($join, &$wp_query) {
global $wpdb;
global $wpdb;
$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";
return $join;
@ -11,25 +11,19 @@ function set_ai1ec_join($join, &$wp_query) {
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");
$now=time();
$where .= ' AND (' . $wpdb->ai1ec_events.start .' >= \''.$now.'\' '.
'OR ' . $wpdb->ai1ec_events.end .' >= \''.$now.'\' )';
$where .= ' AND '. $db_prefix.'ai1ec_events.end >= \''.time().'\'';
return $where;
}
}
function set_ai1ec_limits( $limit, $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
return 'LIMIT 0, 6';
}
return $limit;
return 'LIMIT 0, 5';
}
add_filter('posts_orderby', 'set_ai1ec_orderby');
@ -58,12 +52,20 @@ function get_ai1ec_box($attrs){ ?>
'no_found_rows' => 1,
'posts_per_page' =>$Posts,
'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_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');
@ -111,6 +113,9 @@ function get_ai1ec_box($attrs){ ?>
</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;?>
@ -159,6 +164,9 @@ function get_ai1ec_box($attrs){ ?>
</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;?>
@ -207,6 +215,9 @@ function get_ai1ec_box($attrs){ ?>
</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;?>