WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Previous and next navigation not showing up (12 posts)

  1. voodoodoodoo
    Member
    Posted 4 years ago #

    Hi all,

    I'm really stuck here -- for some reason, the previous and next navigation won't display on our index and archive pages. It works fine on single.php. I tried different themes, moving it around and trying next_posts_link vs. posts_nav_link -- nothing will make it appear.

    The div appears that contains them -- the PHP isn't working for some reason.

    Here's the blog:
    http://depts.washington.edu/alumni/tours/blog/

    Here's the index code:

    <div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> by <?php the_author() ?></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    			</div>
    
    		<?php endwhile; ?>
    
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    </div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    	</div>

    Thanks so much for your help!

  2. henkholland
    Member
    Posted 4 years ago #

    Hi voodoodoodoo
    Under Settings/Reading how many posts do you allow to be displayed?
    I did not see Archives with more than 10 posts. If under Settings/Reading you allow more than 10, the div shows but not the links because they are not needed.
    I see Category Trip reports with 18 entries so perhaps your setting is higher than 18?

  3. voodoodoodoo
    Member
    Posted 4 years ago #

    Hi henkholland,

    Thanks for the response. We've left the default # of posts at 10. The navigation should appear on the main page as well as at least one of the category pages.

    If you look at the source, you'll see the navigation <div> is there, but it's blank -- the PHP isn't working for some reason...

    Any ideas?

  4. henkholland
    Member
    Posted 4 years ago #

    Not many, no.
    Try changing to the wordpress default theme for a minute and see if previous/next navigation works.

    Try setting your permalinks to default and see if previous/next navigation works. Then set them back to what you had as a structure and see again.

    Did the prev-next ever work? Did you do any update that made them missing?

  5. voodoodoodoo
    Member
    Posted 4 years ago #

    Thanks, but alas no luck. I tried a default theme (as well as a couple others) and there was no change.

    Also tried adjusting the permalinks and no change there either. It's baffling.

    I believe they were working before, but it's possible that we just didn't have enough posts where I would notice.

    Anyone else experienced this? Next/prev works on the single.php page.

  6. henkholland
    Member
    Posted 4 years ago #

    Crazy. Offcourse on single.php it is previous_post_link without the "s". I see them above the post content.

    And indeed your trip report archive contains 18 posts; the link shows 10 without a link at the bottom. I even counted through the monthly archives and yes, there are 18 trip reports.

    All I can think of is re-upload: wp-admin and wp-includes (maybe some php file has a glitch)

    Any guru's around??

  7. voodoodoodoo
    Member
    Posted 4 years ago #

    Bumping this up in case anyone else has ideas.
    http://depts.washington.edu/alumni/tours/blog/

    Tinkered around with re-uploading some files with no luck...

  8. voodoodoodoo
    Member
    Posted 4 years ago #

    I finally figured this out. I tried doing a completely different install of WordPress in a new location on our server and had the exact same problem with the pagination links not showing up.

    It was as if next_posts_link and previous_post_link weren't functioning.

    Finally, I figured out a simple fix after looking at the next_posts_link template page on the WordPress codex.

    It turns out I had to specifiy a max_page number even though you shouldn't have to. Some wonky thing with my server? I have no idea, but it finally worked! I changed it to a large arbitrary number - in this case 1000

    <div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries', '1000') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;', '1000') ?></div>
    		</div>

    henkholland - thanks for trying to help.

    No idea if this affects other users. Perhaps I should file a bug?

  9. olesund
    Member
    Posted 4 years ago #

    Okay, this is wierd. It did the trick for me, on a page listing posts, but not in single posts. Also, the links just take me to a page that shows the exact same posts. That is, ...(my blog url)/a-category/page/2 is the same as ...(my blog url)/a-category/page/3.

  10. olesund
    Member
    Posted 4 years ago #

    Found a solution, see this post: http://wordpress.org/support/topic/350033?replies=1

  11. Gorbatshow
    Member
    Posted 4 years ago #

    voodoodoodoo -> Thanks! I used your solution (max_page number) and it finally worked for me.

  12. voodoodoodoo
    Member
    Posted 4 years ago #

    Since I posted the solution, we've moved to WordPress Mu and, strangely, still have this problem. It seems to only happen when I use an instance of WordPress on our servers. It happens with any theme I try, including the new ones for 3.0.

    I made one additional tweak. By setting the max_page number high as I did in the example above, the older link would show up even if there weren't any more entries. So you'd end up clicking on an "Older Posts" link that would be empty.

    I worked around this by getting a count of the number of posts on a page. If that # of posts is greater than or equal to the max # of posts per page that I set in the WP options, then it will display the "older posts" link.

    Here's the example, where I have my posts per page set to 8.

    <div class="navigation">
    <?php
    // Nav to handle error with display of old/new posts. Based on setting for number of posts, which is currently set at 8. If there are 8 posts, then displays the "Older" link, other hides it by limiting max_pages to 1.
    count($posts);
    if (count($posts) > 7) {
    ?>
    	<div class="alignleft"><?php next_posts_link('&laquo; Older Posts', '1000') ?></div>
    <?php
    } else {
    ?>
    	<div class="alignleft"><?php next_posts_link('&laquo; Older Posts', '1') ?></div>
    <?php
    // End of navigation hack
    }
    ?>
    	<div class="alignright"><?php previous_posts_link('Newer Posts &raquo;', '1000') ?></div>
    </div>

    This is a bit of a hack and will still display if there's exactly 8 entries on that page (even if there's no older posts), so it's not perfect. But in case it's helpful for anyone else, I wanted to share.

    And if someone has a more sophisticated way to do this properly, I'm all ears!

Topic Closed

This topic has been closed to new replies.

About this Topic