Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Pagination not working (WP-Page Navi) WordPress

  • SOLVED

Hi There,

I am having trouble with the pagination on my wordpress theme. Its a custom theme built from the ground up.

I am using the wp-page-navi plugin to provide users with a nice easy to use page navigation. The navigation is showing up fine, but when you click on Page 2 it just stays on Page 1. It was working at some point so I obviously did something to mess it up.

Here is the code for my "loop" that pulls in and lists the posts:

<?php $exclude = get_option('ss_blogexclude'); ?>
<?php query_posts('cat=' . $exclude); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>



Here is the code that checks for the page-navi function and displays it if it exists. This bit of code is outside of the loop above.


<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>



Any help is greatly appreciated.

Answers (1)

2010-04-23

Lew Ayotte answers:

Try changing your query post to this:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$exclude = get_option('ss_blogexclude');
query_posts('cat=' . $exclude .'&paged=' . $paged);


Lew


WP Answers comments:

Thanks for the quick reply. When I input that code none of the content on the page loads. Am I inserting it correctly? I replaced my whole loop with this. Is there any part of the old loop I need to keep?


<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php $exclude = get_option('ss_blogexclude'); ?>
<?php query_posts('cat=' . $exclude .'&paged=' . $paged); ?>


WP Answers comments:

I just answered my own question. I needed that last line of code from my loop. Works perfectly! Thank you so much!!

Final working code:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php $exclude = get_option('ss_blogexclude'); ?>
<?php query_posts('cat=' . $exclude .'&paged=' . $paged); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>