I know there about a thousand pagination issue questions on here, and I’ve looked at them, but I can’t seem to figure out what’s going wrong with mine. This is a loop on a custom post type archive template, but it should call ALL POSTS since I’m using it as a blog. At the very top of the template, is a query for a specific page, but I don’t think that’s what’s causing the problem.
What happens is that on the second page I get a 404 error.
<?php get_header(); ?>
<?php // query post #4606
$post_id = 4606;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;?>
<?php echo $title;?>
<!-- The Actual Loop, with a count so that I can style the first post differently -->
<?php $post = $posts[0]; $c=0;
$args = array(
'post_type'=> 'post',
'posts_per_page' => 7,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
);
query_posts($args);
while (have_posts()) : the_post();
?>
<!--Featured Post-->
<?php $c++;
if( !$paged && $c == 1) :?>
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('archive-featured-img', array('class' => 'aligncenter')); ?>
</a>
<?php endif; ?>
<!--the title and content etc.-->
<!--Other Posts-->
<?php else :?>
<!--the title and content for all other posts-->
<?php endif;?>
<?php endwhile; ?>
<!-- The end of the loop -->
<!--Page Navigation-->
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="post-nav" class="cf">
<div class="nav-previous"><?php next_posts_link('Next Page »', 0); ?></div>
<div class="nav-next"><?php previous_posts_link('« Previous Page', 0); ?></div>
</div>
<?php endif; ?>
<?php
wp_reset_query(); // Restore global post data
?>
<!--SIDEBAR--repeats the page title from above, then dynamic sidebar-->
<h1><?php echo $title;?></h1>
<?php echo $queried_post->post_content;?>
<?php dynamic_sidebar( 'Main Blog Page Sidebar' ); ?>
<?php get_footer() ?>
@Milo Thanks, the pre_get-posts seems to work perfectly. I was missing that before, thought my choices were between wp_query and query_posts.
The below should ONLY alter the query on the “rg_blog” custom post type archive, right?