Using Page Navigation with custom time based query
-
I am using a custom query to pull my most recent posts from the last 120 days. I cannot figure out how to get the navigation and paging to work with the query. My code is below.
function filter_where( $where = '' ) { // posts in the last 120 days $where .= " AND post_date > '" . date('Y-m-d', strtotime('-120 days')) . "'"; return $where; } add_filter( 'posts_where', 'filter_where' ); $query = new WP_Query( 'paged=' . get_query_var( 'page' ).'&posts_per_page=9&cat=6&orderby=rand' ); remove_filter( 'posts_where', 'filter_where' );
After the endwhile statement closing the loop, I have the following nav links which produce no navigation.
<div class="nav-previous"> <?php previous_posts_link( __( '<span class="meta-nav">←</span>Go Back', 'twentyeleven' ) ); ?> </div> <div class="nav-next"> <?php next_posts_link( __( 'More in this Gallery<span class="meta-nav">→</span>', 'twentyeleven' ) ); ?> </div>
Any idea how I might add the navigation and paging with my time based query?
Thanks,
–christophe
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Using Page Navigation with custom time based query’ is closed to new replies.