Here is the code:
<?php if ( have_posts() ) : ?>
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=5'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query- >the_post();
?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php higher_content_nav( 'nav-below' ); ?>
<?php $wp_query = null; $wp_query = $temp;?>
<?php endif; ?>
How can I show posts per page not 5 but default? I mean post that we can set at back end at Reading Settings, Blog pages show at most - number of post.
The safest way is to call get_option, which gets the value directly from the database:
$showposts = get_option('posts_per_page');
$wp_query->query('showposts='.$showposts.'&paged='.$paged);
Global variables like $numposts are not guaranteed to be set.
For future reference, you can usually determine what to pass to get_option by finding the name attribute of the setting's <input> in WP Admin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With