WordPress doesn't show more than 10 posts

I am displaying shortcode posts in WordPress posts / pages and want to show an endless list of posts, but it only shows 10 posts.

Here is my code; please tell me what is wrong with my request.

$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; } 
+7
wordpress
source share
6 answers

Just add this to your argument

 'posts_per_page' => -1 

then you are done.

One more thing: you can change the administrator’s default setting to something other than 10. Go to your WordPress admin - Settings - Read. There is an option like "Most popular blog pages." Enter there the number of messages you want by default.

+7
source share

Go to the settings menu on the admin page

Settings → Reading. Change the value of the blog pages no more .

He will work.

+1
source share

A silly question may be, but why do you call $ loop-> the_post (); twice? Isn't that a problem? (each cycle calls 2 messages at a time)

0
source share

You can determine how many posts should appear in the loop:

 <?php wp_reset_query(); ?> <?php $loop = new WP_Query( array( 'post_type' => 'resource', 'order_by' => 'post_id', 'order' => 'ASC', 'post_status' => 'publish', 'posts_per_page' => 100 ) ); ?> <?php while ($loop -> have_posts()): $loop -> the_post(); ?> <h1><?php the_title(); ?></h1> <p><?php the_content(); ?></p> <?php endwhile; ?> 
0
source share

1) First I advise you to always post on Wordpress.Stackexchange.com

2) The best way is to add to functions.php :

 add_action('pre_get_posts','myfunc'); function myfunc($query){ if ($query->is_main_query() && $query->is_archive){ $query->set( 'posts_per_page', 1000); } return $query; } 
0
source share
 'posts_per_page' => -1 

or

 'posts_per_page' => 1000 

Both should work.

0
source share

All Articles