$wp_query, &paged, and page navigation
-
Hi all,
I am working on an image gallery where users can scroll through posts via pictures only. It is a combination of the tim thumbs code and some custom work. You can find the image gallery here:
http://www.bespokeordie.com/image-gallery/
I am using the following code: The first and last block are a wp_query trick I was hoping would help to get my pagination working, but it did not work. I am using a hardcoded version of Lester Chan’s plugin.
<?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('&posts_per_page=30'.'&paged='.$paged); ?> <?php if (have_posts()) { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("&posts_per_page=30&paged=$paged"); } while(have_posts()) { the_post(); get_image('image','thumbnail','','','thumbnail gallery'); } ?> <?php $wp_query = null; $wp_query = $temp;?>Anyone have any thoughts or suggestions how to get my pagination on this page to match that of my site which uses the following code:
<?php if (function_exists(‘wp_pagenavi’)) { ?><?php wp_pagenavi(); ?><?php } ?>
Right now I am using the following, but without the first and last block of the code noted above:
<?php posts_nav_link(‘ – ‘,’Previous Page’,’Next Page’); ?>
-
Based on the code you are displaying, don’t know why you need that first block of code.
<?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('&posts_per_page=30'.'&paged='.$paged); ?>I have tried it with it and without it, but had no luck.
I read this article, maybe the Lester Chan plugin does not work with my query code then?
So, to close up the post, the short answer is that with the “&paged” and “$wp_query” the Lester Chan pagination does not work. The answer is much more complicated than I profess to understand. But, the standard pagination code does work.
Try this:
<?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('&posts_per_page=30'.'&paged='.$paged); if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); get_image('image','thumbnail','','','thumbnail gallery'); } ?> <?php $wp_query = null; $wp_query = $temp;?>
The topic ‘$wp_query, &paged, and page navigation’ is closed to new replies.