Forums

previous_post_link & next_post_link not working (9 posts)

  1. meglundy
    Member
    Posted 2 years ago #

    I am unable to make the previous_post_link & next_post_link work correctly on my custom wordpress site.

    Can anyone help me, please refer to the code and link below.

    http://www.bundles-of-babies.com/wordpress

    [please mark any code using the 'code' button; and in future, please use the pastebin for any code longer than 10 lines]

    <?php query_posts('category_name=testimonials&showposts=1'); ?>
    			<?php if (have_posts()) : ?>
    			<?php while (have_posts()) : the_post(); ?>
                	<h2>Staff</h2>
          <a href="wordpress/testimonials"><h1><?php the_title(); ?></h1></a>
                    <img src="/images/top_background.png" width="486" height="16">
                    <div class="entry">
    				<?php the_content(); ?>
                     <img src="/images/testimonials_line.jpg" width="289" height="22" align="left">
    				<?php previous_post_link(); ?>
    				<?php next_post_link(); ?>
    				</div>
               	<?php endwhile; ?>
                <?php endif; ?>
  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    as this code is not in single.php, try next_posts_link() and previous_posts_link()

    http://codex.wordpress.org/Function_Reference/next_posts_link
    http://codex.wordpress.org/Function_Reference/previous_posts_link

  3. meglundy
    Member
    Posted 2 years ago #

    Thanks! The navigation is now appearing but the actual content is not changing when clicking on the navigation. Its strange there are 4 posts in the category I am querying and in the menu bar you can see the pages changing but the content stays the same??

    Thoughts??

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    the pagination parameter is missing in the query:
    http://codex.wordpress.org/Function_Reference/WP_Query#Pagination_Parameters

    try:

    <?php query_posts('category_name=testimonials&showposts=1&paged=' .get_query_var('paged')); ?>
  5. BennyBoy82
    Member
    Posted 2 years ago #

    Hi i was hoping that somebody might be able to help me out. I dont know whats caused this to happen but my blog page isn't working anymore, has anyone got any ideas? my domain is http://www.rumdumbar.com.

    I cant access or comment on any of my posts and before i could. Why has this happened?

    Im a novice with wordpress so please be clear with your instructions.

    Many Thanks

    Ben

  6. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    @BennyBoy82

    please start a new topic.

  7. meglundy
    Member
    Posted 2 years ago #

    Thank you so much for you help! This works great.

    Now my one and final question: Is there a way to have the links always appear, even if there are no more posts to cycle through?

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    not as links; however, you can have some output instead:

    see if you can get the idea from this snippet:

    <div class="navigation">
    	<div class="alignleft"><?php if(get_next_posts_link()) { next_posts_link('&laquo; Older Entries'); } else { echo 'No Older Entries'; } ; ?></div>
    
    	<div class="alignright"><?php if(get_previous_posts_link()) { previous_posts_link('Newer Entries &raquo;'); } else { echo 'No Newer Entries'; } ; ?></div>
    </div>
  9. meglundy
    Member
    Posted 2 years ago #

    THANKS!!!!!!!

    You Rock!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.