Paginate WordPress Query?
-
I’m trying to add pagination to a custom query that pulls the top voted articles from the DB. After every two articles I’m trying to insert something, via a count. So far my efforts have been pretty bad, the count is screwed and I have no idea how pagination fits in.
so…
-Grab top voted posts & order them.
-After every two posts/articles, insert extra content, using a count.
-pagination needed for my many pages of content.<?php // grab top voted posts in order (works okay) $query_sql = "SELECT like_pid FROM " . $wpdb->prefix ."likes_count ORDER BY like_count DESC"; $query_result = $wpdb->get_col( $wpdb->prepare ($query_sql, OBJECT)); if ($query_result) { foreach ($query_result as $post_id) { $post = &get_post( $post_id ); setup_postdata($post); ?> // Now count out two articles (fail?) <?php $count++; ?> <?php if ($count%2== 0) : ?> // Show the two articles <?php else : ?> //Now do something else <?php endif;?> <?php } ?> <?php } ?> <div class="next"> <?php next_posts_link('»' ,0); ?></div> <div class="previous"> <?php previous_posts_link('«' ,0); ?>
Any help appreciated much.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Paginate WordPress Query?’ is closed to new replies.