Replies: 0
Hi–
I’m trying to paginate pages of posts that use the widget WP_Widget_Categories as a dropdown, but it doesn’t seem to get past page 1.
My code:
<?php the_widget( 'WP_Widget_Categories', 'dropdown=1&count=1' ); ?>
<br>
<?PHP
$temp = $wp_query;
$args=array('posts_per_page' => 5,'paged' => get_query_var('page'));
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query($args);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<p><span class="newsDate"><?PHP echo the_date(); ?></span><br>
<h2 class="newsHead"><a href="<?php the_permalink(); ?>" title="Read more"><?php the_title(); ?></a></h2>
<?PHP the_excerpt(__('(more…)')); ?>
<br>
<?php endwhile; ?>
<?php if ($paged > 1) { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Previous Posts'); ?></div>
<div class="next"><?php previous_posts_link('Newer Posts »'); ?></div>
</nav>
<?php } else { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Previous Posts'); ?></div>
</nav>
<?php } ?>
<?php //wp_reset_postdata(); ?>
My page works fine as long as I don’t change the dropdown to another category, but if I do, I only see the first 5 posts. The URL changes page numbers when I click the links, but the content never changes.
Any ideas?
Thank you!!
- This topic was modified 9 minutes ago by hank scorpio.