How to Customize Number of Posts in WordPress Page Navigation


By default, WordPress displays 10 posts in wordpress page navigation. But sometimes we just want to change the number of posts and display more or less posts, here’s how to achieve it. The solution is pretty simple: use the query_posts() function, which gives you a total control over the WordPress loop. The showposts parameter determines how many posts will be displayed per page.

Find the wordpress loops like this:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// WordPress loop
<?php endwhile;endif; ?>

Change it as illustrated below:

<?php
$page_num = $paged;
if ($pagenum='') $pagenum =1;
query_posts('showposts=7&paged='.$page_num); ?>

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// WordPress loop
<?php endwhile;endif; ?>

<?php wp_reset_query(); ?>

Note: If you use query_posts(), make sure you call wp_reset_query() after you’re done. Or something will be wrong query posts.

See also  50+ Beautiful Country Kitchen Design Ideas for Inspiration

Leave a Reply

Your email address will not be published. Required fields are marked *