The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] 404s beyond page 2 (3 posts)

  1. lukeshumard
    Posted 6 years ago #

    I'm pulling my hair out trying to get pagination to work on my site. My pagination shows up, and works when I edit the variables for 'posts_per_page' in my query. However, it will only show the first and second page, and the third (http://dev.lukeshumard.com/chromeleaf/page/3/) is always a 404 error. My permalink structure is set up to /%year%/%monthnum%/%day%/%postname%/. I have WP-Paginate installed, here is my code for index.php.

    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    		$args= array(
    					 'cat' => 1,
    					 'posts_per_page' => 1,
    					 'paged' => $paged
    					 ); ?>
    	<?php query_posts($args); ?>
    	<?php if (have_posts()) : ?>
        	<?php while (have_posts()) : the_post(); ?>
            <div class="post">
            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <small><?php the_time('F jS, Y') ?></small>
    			<div class="entry">
    			<?php the_content(); ?>
            <div class="divide"></div>
        <?php endwhile; ?>
        	<?php if(function_exists('wp_paginate')) { wp_paginate(); } ?>
        <?php else: endif; ?>

    The only other plugins I have installed are GigPress, Contact Form 7, and WP No Category Base (which I've tried deactivating in case that did anything).

    I am completely stumped, and can't help but wonder if I'm overlooking something incredibly simple. I've searched through a few threads slightly similar to this, but I couldn't find a straight answer. Anyone?

  2. Eric Martin
    Posted 6 years ago #

    That is really strange.

    Have you tried printing out $args to see if something is changing?

    I think you'd have to investigate on a lower level to see what is going on. As far as I can tell, the plugin is doing what it is supposed to...

  3. lukeshumard
    Posted 6 years ago #

    the solution to this was this code...

    $limit = get_option('posts_per_page');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('showposts=' . $limit . '&paged=' . $paged .'&cat=1');
    $wp_query->is_archive = false;
    $wp_query->is_home = true;

    ...and that worked for me. i forget what page that information came from.

Topic Closed

This topic has been closed to new replies.

About this Topic