Any tips on fitting pagination into my loop below and I owe you a beer or two. I’ve worked out how to pull the top rated articles by vote from a custom plugin, and lay it out with a count, but pagination has me stumped. I’m a self-taught learner here so any help would be greatly appreciated.
I was aiming for 6 posts shown per page then use pagination if needed.
Two posts are shown and after that a new code section is inserted with a count, the count works, everything works except pagination.
Not sure how this fits in
'$wp_query->query('showposts=6'.'&paged='.$paged);
when I already use
DESC LIMIT 6 OFFSET 0
in my query…
<?php global $wpdb;
$query_sql = "SELECT like_pid FROM " . $wpdb->prefix ."likes_count ORDER BY like_count DESC LIMIT 6 OFFSET 0";
$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); ?>
<?php $count++;
if ($count%2== 0) : ?>
<-- do the loop, count out two articles -->
<?php else : ?>
<-- do something after every two articles -->
<?php endif;?>
<?php } ?>
<?php } ?> //ugly but works
<div class="next"> <?php next_posts_link('»' ,0); ?></div>
<div class="previous"> <?php previous_posts_link('«' ,0); ?></div>
This should get the offset for you, and from there it’s a simple matter of adjusting your query