J'ai essayé plusieurs boucles différentes pour afficher le message le plus consulté des 30 derniers jours. . Cependant, il suffit de montrer le message d'il y a 30 jours. . pas des 30 derniers jours. . pas le plus vu. . Si quelqu'un peut m'aider. .il sera fantastique, merci =)
Voici ma boucle en ce moment:
<ul>
<?php
function filter_where($where = '') {
//posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts('post_type=post&posts_per_page=3&orderby=post_views_count&order=ASC');
while (have_posts()): the_post(); ?>
<li><div class="tabber-image">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('small-thumb'); ?></a>
</div>
<div class="tabber-text">
<?php
//$meta = get_post_meta(get_the_ID());
//$short_title = $meta['maxmag_featured_headline'][0];
?>
<a href="<?php the_permalink() ?>" class="main-headline"><?php the_title(); ?></a></li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
Toute aide serait incroyable. .Merci pour votre temps
MODIFIER ---
Dernière boucle:
<ul>
<?php while (have_posts()) : the_post();
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'order'=> 'ASC',
'date_query' => array(
array(
'after' => '30 days ago'
),
),
);
$query = new WP_Query( $args );
?>
<li>
<div class="tabber-image">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('small-thumb'); ?></a>
</div>
<div class="tabber-text">
<?php
//$meta = get_post_meta(get_the_ID());
//$short_title = $meta['maxmag_featured_headline'][0];
?>
<a href="<?php the_permalink() ?>" class="main-headline"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
CODE ORIGINAL DU PLUGIN:
<div id="tab2" class="tabber-content">
<?php $popular_posts = new WP_Query('showposts=' . $popular_number . '&orderby=comment_count&order=DESC'); if($popular_posts->have_posts()): ?>
<ul>
<?php while($popular_posts->have_posts()): $popular_posts->the_post(); ?>
<li>
<div class="tabber-image">
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('small-thumb'); ?></a>
<?php } ?>
</div>
<div class="tabber-text">
<a href="<?php the_permalink() ?>" class="main-headline"><?php the_title(); ?></a>
<p><?php echo excerpt(10); ?></p>
<div class="headlines-info">
<ul class="headlines-info">
<li>Posted <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?></li>
<li class="comments-icon"><a href="<?php comments_link(); ?>"><?php comments_number( '0', '1', '%' ); ?></a></li>
</ul>
</div><!--headlines-info-->
</div>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div><!--tab2-->
Essaye ça:
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'order'=> 'ASC',
'date_query' => array(
array(
'after' => '30 days ago'
),
),
);
$query = new WP_Query( $args );
Vous ne pouvez pas commander directement par le nom de met_key, vous devez l’utiliser comme ci-dessus.