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; ?>
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??
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')); ?>
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
@BennyBoy82
please start a new topic.
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?
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('« Older Entries'); } else { echo 'No Older Entries'; } ; ?></div>
<div class="alignright"><?php if(get_previous_posts_link()) { previous_posts_link('Newer Entries »'); } else { echo 'No Newer Entries'; } ; ?></div>
</div>
meglundy
Member
Posted 2 years ago #