Wordpress loop show limit posts

后端 未结 5 1911
终归单人心
终归单人心 2020-12-10 15:59

This is the basic loop

I want to show 20 posts on the search results page. I know we can chang

5条回答
  •  抹茶落季
    2020-12-10 16:32

    I find this solution and it works for me.

     global $wp_query;
     $args = array_merge( $wp_query->query_vars, ['posts_per_page' => 20 ] );
     query_posts( $args );
    
     if(have_posts()){
       while(have_posts()) {
         the_post();
         //Your code here ...
       }
     }
    

提交回复
热议问题