Hi all :)
I've got the perfect filter for 'Most Popular Articles Within The Last 7 Days' working, but the only thing that still isn't working is that it's not adding the pagination?
I'd assumed 'paged' => $paged would work within the $args, but it's not?
I was wondering if anyone could tell me why the pagination isn't being added?
<h1>Most Popular Now</h1>
<div class="post-links">
<?php
function filter_posts($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_posts');
$args = array(
'category__in' => array(2),
'posts_per_page' => 12,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'paged' => $paged
);
$filter_posts_query = new WP_Query($args);
remove_filter('posts_where', 'filter_posts');
//loop for displaying posts
if ( $filter_posts_query->have_posts() ) :
while ($filter_posts_query->have_posts()) : $filter_posts_query->the_post();
?>
<?php do_action( 'bp_before_blog_post' ); ?>
<a href="<?php the_permalink() ?>" class="post-link">
<strong><?php the_title(); ?></strong>
<?php
ob_start();
the_content( __( 'Read the rest of this entry →', 'buddypress' ) );
$old_content = ob_get_clean();
$new_content = strip_tags($old_content);
echo $new_content;
?>
<span class="post-link-action">Read more ►</span>
</a>
<?php do_action( 'bp_after_blog_post' ); ?>
<?php endwhile; ?>
<?php bp_dtheme_content_nav( 'nav-below' ); ?>
<?php else : ?>
<h2 class="center"><?php _e( 'Not Found', 'buddypress' ); ?></h2>
<p class="center"><?php _e( 'Sorry, but you are looking for something that isn\'t here.', 'buddypress' ); ?></p>
<?php get_search_form(); ?>
<?php endif; ?>
</div>
Thanks! :)