WordPress.org

Ready to get started?Download WordPress

Forums

next_posts_link not showing up (10 posts)

  1. bestftp
    Member
    Posted 3 years ago #

    For some reason next_posts_link is not working or even showing up on my site. I have searched for days trying to resolve this issue, but have not been able to find a solution. Any help would be greatly appreciated. Below is the code for the loop in the index page.

    [Link Removed]

    '<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="videoitem">
    <div class="ratings">
    <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
    </div>

    <div class="comments">
    <?php comments_number('0', '1', '%'); ?>
    </div>

    <div class="thumbnail">
    " title="<?php the_title() ?>"><img style="background: url(<?php $key="thumbnail"; echo get_post_meta($post->ID, $key, true); ?>)" class="thumb" src="<?php bloginfo('template_url'); ?>/images/zoom.png" alt="<?php the_title() ?>" />
    </div>

    <h2 class="itemtitle">" title="<?php the_title() ?>"><?php the_title() ?></h2>
    <p class="itemdesc"><?php the_content_rss('', TRUE, '', 8); ?></p>
    <small class="gallerydate"><?php the_time('F j, Y'); ?></small>
    </div>
    <?php endwhile; else: ?>
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    </div>
    <?php endif; ?>'

  2. mrmist
    Forum Janitor
    Posted 3 years ago #

    In this case I don't see that a link to an adult site adds particular value to the question, so link removed.

    Does previous posts link show up, is it just next posts that doesn't work?

    Consider that it will only show up if there are next posts to show...

  3. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    the 'prev/next' link code is in the else section of the if(have_posts()) statement (where it could only be shown if there were no posts on the page, and then there would be no next/prev posts, so the code would not be shown anyway ....);

    move it to after the endif;

    <?php endwhile; else: ?>
    <?php endif; ?>
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    </div>
  4. bestftp
    Member
    Posted 3 years ago #

    @alchymyth I tried moving it after <?php endif; ?>, but it still does not display. Here is what the current code looks like.

    <?php get_header(); ?>
    
        <div id="contentwrap">
        	<div id="content">
                <div id="contentleft">
                    <div id="menubar">
                        <div id="catlist">
                            <ul class="menu">
                                <li><a href="#menu" onclick="javascript:showlayer('sm_1')">Select a Category</a></li>
                            <ul class="submenu" id="sm_1">
                                <?php wp_list_categories('exclude=9,7,8'&title_li=); ?>
                            </ul>
                            </ul>
                        </div>
    
                        <a title="Subscribe to Content via RSS" href="<?php bloginfo('rss2_url'); ?>"><div id="subscribe"></div></a>
                    </div>      
    
                    <div id="videogallery">
                    <?php query_posts('cat=-4'); ?>
                    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    	<div class="videoitem">
                        	<div class="ratings">
                            	<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
                            </div>
    
                            <div class="comments">
                            	<?php comments_number('0', '1', '%'); ?>
                            </div>
    
                            <div class="thumbnail">
                            	<a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><img style="background: url(<?php $key="thumbnail"; echo get_post_meta($post->ID, $key, true); ?>)" class="thumb" src="<?php bloginfo('template_url'); ?>/images/zoom.png" alt="<?php the_title() ?>" /></a>
                            </div>
    
                            <h2 class="itemtitle"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_title() ?></a></h2>
                            <p class="itemdesc"><?php the_content_rss('', TRUE, '', 8); ?></p>
                            <small class="gallerydate"><?php the_time('F j, Y'); ?></small>
                        </div>
                    <?php endwhile; else: ?>
    
                    <?php endif; ?>
    
                    <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>
    
            </div>
                </div>
    
                <div id="contentright">
                    <?php get_sidebar(); ?>
                </div>
            </div>
    	</div>
    
    <?php get_footer(); ?>
  5. bestftp
    Member
    Posted 3 years ago #

    @mrmist neither the next nor previous post links show up. and yes there are more posts to show.

  6. bestftp
    Member
    Posted 3 years ago #

    Can anyone figure out why the next posts and previous posts are not showing up? Please! This is driving me crazy. I see no reason why they are not showing up at all.

  7. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    if you look at the html code from the browser ('view' 'source'), what is showing there for the links?

    just the empty html divs like so?

    <div class="navigation">
    			<div class="alignleft"></div>
    			<div class="alignright"></div>
    		</div>

    alternative try:

    move the 'next/prev' link code to inbetween endwhile; and else :

    </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: ?>
                    <?php endif; ?>
  8. bestftp
    Member
    Posted 3 years ago #

    If i view the source, there is nothing there. It doesn't display empty divs or anything. It shows the last post followed by the right sidebar.

    I have also tried moving the navigation div in between endwhile and endif, but it gives the same result.

  9. bestftp
    Member
    Posted 3 years ago #

    I was able to get it working by editing the home.php file instead of the index.php file. However, upon clicking the previous button it does not show older posts. It simply refreshes the page with the same posts that were before displayed before. Any ideas?

  10. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    the file is using a custom query:

    <?php query_posts('cat=-4'); ?>

    which is missing the 'paged' parameter - try to expand it like so:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=-4&paged=' . $paged'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic