I have a category template with a custom post type that looks like:
<?php
$category = get_query_var('cat');
$paged = (get_query_var("page")) ? get_query_var("paged") : 1;
$args = array(
'cat' => $category,
'paged' => $paged,
'post_mime_type' => 'image',
'posts_per_page' => 9,
'post_status' => 'inherit',
'post_type' => 'attachment'
);
query_posts($args);
$count = $wp_query->found_posts;
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php echo wp_get_attachment_image($image->ID, "medium"); ?></a>
<h5><?php the_title(); ?></h5>
<?php
$attachment = get_post(get_post_thumbnail_id()); // Get post by ID
echo '<p>'.$attachment->post_content.'</p>'
?>
<?php endwhile; endif; ?>
<ul class="pagi">
<li><?php posts_nav_link(' | ','< Previous','Next >'); ?></li>
<li><?php echo "(Page: ". $paged . " of " . $wp_query->max_num_pages .")"; ?></li>
</ul>
<?php wp_reset_query(); ?>
Everything is working except the paging...when I view page 2 the url looks like: http://joshrodg.com/ourpictureshare/category/pictures/unknown/page/2/, which is a 404.
I'm not sure what the URL is supposed to look like, but I think the post type in my query is causing the issue.
Could someone point me in the right direction?
Thanks,
Josh
pre_get_posts
to alter the main query instead of creating a new query in the template.