posts pagination in wordpress
i want to show 4 posts in page and after 4 posts it will show next button to read next posts.
<?php while (have_posts()) : the_post(); ?>
<?php
global $post;
$myposts = get_posts('numberposts=4&order=ASC&category=3');
foreach($myposts as $post) :
setup_postdata($post);
?>
here is content with html
开发者_C百科 <?php endforeach; ?>
<?php endwhile; ?>
<?php endif; ?>
You just need to add paged
parameter to your query_posts:
$myposts = get_posts('numberposts=4&order=ASC&category=3&paged' . get_query_var('paged'));
And add post_nav_link() to display next
and prev
link.
<?php posts_nav_link(); ?>
Cheers, oh, btw, you can post specific wordpress question at wordpress.stackexchange.com.
精彩评论