Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress not showing more than 10 posts

Tags:

wordpress

I am showing posts by shortcode into posts/pages of WordPress, and want to show an infinite list of posts, but it is showing only 10 posts.

Here is my code; please guide me what is wrong with my query.

$args = array( 'post_type' => 'post', 'cat' => '2', 'meta_key' => 'issue_of_article', 'meta_value' => $issue, 'posts_per_page' => -1, 'orderby' => 'artcle_category', 'order' => 'ASC');
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
     $loop->the_post();
     <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
endwhile;
}
like image 400
mian ji Avatar asked Jan 20 '14 10:01

mian ji


2 Answers

Just add this in your argument

'posts_per_page' => -1

then you are done.

One more thing: you can change the default setting from admin to something other than 10. Go to the WordPress admin - Settings - Reading. There is an option like "Blog pages show at most". Type there the number of posts you want as the default.

like image 187
Jenish Mandalia Avatar answered Oct 19 '22 06:10

Jenish Mandalia


Go to settings menu in the admin page

Settings -> Reading Change the value for Blog pages show at most.

It will work.

like image 3
Leo T Abraham Avatar answered Oct 19 '22 05:10

Leo T Abraham