pipedragon72
Member
Posted 1 year ago #
I'm trying to add a next page link to a page template I have set up. The template lists 4 posts. I want the next posts (ie 5-8) to show when the user clicks on the next page link but it's showing the new page (ie page_id=20&paged=2) but the same posts are in it.
I'm probably missing something here; is it actually possible to do this and if so, does anyone know how?
what is the code of the custom query on your page template?
(if it is longer than a few lines, please use the http://pastebin.com/)
the query is probably missing the pagination parameter:
http://codex.wordpress.org/Function_Reference/WP_Query#Pagination_Parameters
(try 'paged' insted of 'page' if the code is not working first time.)
pipedragon72
Member
Posted 1 year ago #
hi alchymth
the code i'm using is:
<ul class="gallery">
<?php query_posts( array ( 'category_name' => 'Commercial', 'posts_per_page' => 4 ) );?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="#" class="thumb"><span><img src="<?php $thumb = get_post_meta($post->ID, 'thumb', true); ?><?php echo $thumb; ?>" alt="" /></span></a>
<div class="cont"><h2><strong><?php the_title(); ?></strong></h2><?php the_content(); ?></div>
<div class="large"><?php if ( has_post_thumbnail()) the_post_thumbnail('cat-thumb'); ?></div></li>
<?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
<?php else : ?>
<?php endif; ?>
</ul>
<p class="clear"><?php posts_nav_link(); ?></p>
does wordpress automatically create a new page for me or do i need to do that and then specify which posts? am a little confused!
does wordpress automatically create a new page
this works automatically
this is the custom query line i was talking about:
<?php query_posts( array ( 'category_name' => 'Commercial', 'posts_per_page' => 4 ) );?>
try and change it to:
<?php query_posts( array ( 'category_name' => 'Commercial', 'posts_per_page' => 4, 'paged' => get_query_var('paged') ) );?>
pipedragon72
Member
Posted 1 year ago #
aha! yes that's it. THANK YOU :o)