WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin WP-Pagenavi] Custom query not showing paginated posts (3 posts)

  1. Flabadab
    Member
    Posted 2 years ago #

    Hi Guys,

    I'm using WP-PageNavi in a custom page template. The pagination works great, the page numbers are generated, but when I click on the "2" or next page button I get redirected to a 404 page. It all worked perfectly until I updated my WordPress to 3.3.1 and I also updated the WP-Pagenavi to 2.82. It was silly not to make a backup before hand, I know, but hind-sight is 20/20.

    SO here's my code:

    <div id="listings">
    			<ul id="search_table">
    				<?php while ($search_result_query->have_posts()) : $search_result_query->the_post(); ?>
    				<?php include 'includes/variables.php' ?>
    				<li style="border-right:2px #666 solid; width:525px; padding-left:5px;">
    					<?php
    			// get first image from list of images
    				$arr_sliderimages = get_gallery_images();
    
    				$firstimage = $arr_sliderimages[0];
    				//echo $firstimage;
    				$arr_sliderimages = parse_url($firstimage);
    				$resized = timthumb(150, 200, $arr_sliderimages[path], 1);
    
    			?>
    					<a href="<?php the_permalink(); ?>"><img class="loader" width="150" height="100" alt="Image for <?php echo $address; ?>" src="<?php echo $resized; ?>" /></a>
    					<h4 class="vehiclename"> <a href="<?php the_permalink(); ?>"><?php echo $manufacturer_level1 ?> -
    						<?php the_title(); ?>
    						<?php echo $year ?> <?php echo $body_type ?></a> </h4>
    					<div class="otherinfo"><?php echo get_post_meta($post->ID, "otherfeatures_value", true); ?></div>
    				</li>
    				<?php include 'includes/twofeatures_home.php'; ?>
    				<li style="border-right:2px #666 solid; width:70px;">
    					<?php the_time('d/m/Y'); ?>
    				</li>
    				<li style="border-right:2px #666 solid; width:70px;">
    					<?php include 'includes/price.php';  ?>
    				</li>
    				<li style="width:100px; text-align:center;" align="center"><a style="width:100px; text-align:center;" href="<?php the_permalink(); ?>"><img class="result_icon" src="<?php bloginfo ('url'); ?>/wp-content/themes/automotiv/images/mag.png" width="32" /></a></li>
    				<?php if ( is_user_logged_in() ){ ?>
    				<?php edit_post_link('Edit this listing.'); ?>
    				<?php } ?>
    				<div class="clearfix_line"></div>
    				<?php endwhile; ?>
    			</ul>
    			<?php wp_pagenavi( array ( 'query' => $search_result_query ) );
    			wp_reset_postdata(); ?>
    		</div>

    Any help in figuring out where I've gone wrong would be fantastic...?

  2. scribu
    Member
    Posted 2 years ago #

  3. Flabadab
    Member
    Posted 2 years ago #

    I see I forgot to include the actual query...but yes, I have included the paged parameter.

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    $wpq = array ('post_type' =>'listing', 'paged' => $paged, 'order' => 'DESC', 'post_status' => 'publish', 'posts_per_page' => 10);
    
    $search_result_query = new WP_Query($wpq);

Topic Closed

This topic has been closed to new replies.

About this Topic