Pagination doesn't work
-
Hi There,
I’ve tried to add a pagination to my query but can’t make it work.
When I click to get to my second page of posts I just get same list of post as the first page. Nothing change.I can’t see from where is the issu. I have $paged and a link at the bottom to get the second page.
If I move $paged before $wp_query = new WP_Query(); I don’t get any result??Thanks for helping me.
<?php //Create a new filtering function that will add our where clause to the query function filter_where($where = '') { //posts in the last 30 days $where .= " AND post_date < '" . date('Y-m-d') . "'"; return $where; } // Register the filtering function add_filter('posts_where', 'filter_where'); // Perform the query, the filter will be applied automatically $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('category_name=events&posts_per_page=10&order=DSC&orderby=date&post_date='.date('Y-m-d', strtotime('-300 days')).'&paged='.$paged.'');?> <?php while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php $custom_fields = get_post_custom(); $my_custom_field = $custom_fields['eventdate']; foreach ( $my_custom_field as $key => $value ) { echo "<div class='eventdate'><p>$value</p></div>"; } ?> <h2 class="entry-title"><?php the_title(); ?></h2> <div class="entry-content"> <?php the_post_thumbnail('large'); ?> <?php the_content(); ?> </div><!-- .entry-content --> </div><!-- #post-## --> <?php endwhile; ?> <div class="pagination-events"> <?php previous_posts_link('Upcoming Events'); ?><?php next_posts_link('Past Events'); ?> </div> <?php wp_reset_query(); ?>
- The topic ‘Pagination doesn't work’ is closed to new replies.