For some reason the below code works until I hit the third page and gives 404. Is it possible to fix it without using any plugins?
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query('cat='. $id .'&posts_per_page=4&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php get_the_content() ?>
<?php endwhile; ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php previous_posts_link( __( 'Previous', 'themename' ) ); ?>
<?php next_posts_link( __( 'Next', 'themename' ) ); ?>
<?php endif; ?>
<?php $wp_query = null; $wp_query = $temp;?>
Try creating a new instance of WP_Query and at the end use wp_reset_query(); like this:
Here is some working code i use: