How to limit post on wordpress
The solution is simple:
You have to use the query_posts() function, which gives you a total control over the WordPress loop.
You have to use the query_posts() function, which gives you a total control over the WordPress loop.
To specify how many posts you want to be displayed per page, we’ll use the showposts parameter.
Here’s an example:
<?php
$page_num = $paged;
if ($pagenum='') $pagenum =1;
query_posts('showposts=5&paged='.$page_num); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// WordPress loop
endwhile;endif; ?>
$page_num = $paged;
if ($pagenum='') $pagenum =1;
query_posts('showposts=5&paged='.$page_num); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// WordPress loop
endwhile;endif; ?>
This example loop will displays 5 posts per page.
’.$page_num parameter
allows use to display our content by pages and use a paginator.
No comments:
Post a Comment