• Resolved adz

    (@adz)


    Hi

    I’ve been working on a particular website all day, and it just seems that the moment I fix one thing, another thing breaks. Now it’s the turn of the posts_nav_links().

    I originally omitted it from the template (I created it myself) but changed my mind – I don’t want to set posts_per_page=-1.
    The first place I put it in was archive.php.

    I’m running one testbed locally and one live on the net – both are as identical as possible (minor configuration differences exist), and have the same issue.

    For testing purposes set posts_per_page=2. I navigate to domainroot/2010/04 and it loads the archive for April 2010 with the two newest posts, as expected. But when I click on the next page link, it comes up with the “page not found” message – which is what it’s been set to show in the else section of The Loop. On my local test machine, page/2/ comes up with the error. On the server page/2/ works but page/3/ doesn’t.

    I can’t make sense of it.
    I’m using WP 2.9.2, and I’ve got the WP No Category Base plugin enabled. I thought that the plugin may be causing the issue, but it’s still broken after I disabled the plugin.

    Any help would be much appreciated.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter adz

    (@adz)

    Sorry to bump my own thread, but anyone have any ideas?

    At least show the code that you’re using. Probably you’re missing some arguments or need some filter.

    Thread Starter adz

    (@adz)

    archive.php

    <?php get_header(); ?>
    <div id="container">
        <?php get_sidebar(); ?>
    
    	<div id="rightcolumn" class="rightcolumn">
        	<?php  query_posts($query_string . '&posts_per_page=2'); ?>
    		<?php if ( have_posts() ) : ?>
            <?php while ( have_posts() ) : the_post(); ?>
            	<div class="post" id="post-<?php echo $post->ID ?>">
                    <?php edit_post_link('[Edit]', '<div class="edit">', '</div>'); ?>
                    <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                    <span class="archiveCatName">
                    <?php
    					foreach((get_the_category()) as $category) {
    						echo(get_category_parents($category->cat_ID ,TRUE, ' '));
    						echo '<br />';
    					} 
    
    				?>
    				</span>
                    <span class="newsDate"><?php the_time('l, F jS Y') ?></span>
    
    			</div><!--End Post-->
    		<?php endwhile;
    		posts_nav_link();
    		else: ?>
    			<h2>Page Not Found</h2>
    			<p>Sorry, the page you were looking for could not be found.</p>
    		<?php endif; ?>
        </div> <!--End Right Column-->
        <br />
        </div> <!--End Container-->
       <?php get_footer(); ?>

    I’m using it without any parameters at the moment until I can get it working properly.

    Thread Starter adz

    (@adz)

    It’s decided to use the index.php template rather than archive.php so for some reason, it’s not detecting that it’s an archive. I don’t think the problem is with posts_nav_link() but I don’t have a clue what the problem is.

    Michael

    (@alchymyth)

    you could try and add the ‘paged’ parameter.
    the codex is not very helpful there; but see this article:
    http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/

    Thread Starter adz

    (@adz)

    @alchymyth – Thanks for the idea, but I’ve already tried that. It didn’t make a difference. Just for the sake of testing, I also tried navigating to domainroot/2010/?paged=2 but still no luck.

    It can’t work like that.

    Create a filter, place it in functions.php instead of querying directly within the archive.php template. Unless the no. of posts per page you set in Options Settings > Reading not exceed the total no. of posts that exist in that category then you can use query_posts() like that. AFAIK.

    Thread Starter adz

    (@adz)

    @zeo – I have no idea what sort of filter you want me to create and what to do with it. Could you explain it please?

    Thread Starter adz

    (@adz)

    Thank you Zeo. I initially left the posts_per_page in the query string which gave me an odd result – I could get to page 2, but not 3. Once I removed that, it worked perfectly. Thanks again.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘posts_nav_link – Page Not Found’ is closed to new replies.