Good evening!

I have a page with medical services ( page ). The page displays 10 services. How to display not 10, but all?

Page code: `

<section id="content"> <div class="container"> <div class="row"> <div class="<?php gg_page_container(); ?>"> <?php if (have_posts()) : // Queue the first post. the_post(); // Rewind the loop back rewind_posts(); ?> <div class="gg_posts_grid"> <ul class="el-grid no_magnific" data-layout-mode="fitRows" data-gap="gap"> <?php while (have_posts()) : the_post(); ?> <li class="isotope-item col-md-12"> <?php set_query_var( 'medical_services_thumb', 'medical-services-thumb-1col' ); get_template_part( 'parts/medical-services/part','medical-service' ); ?> </li> <?php endwhile; ?> </ul> </div> <?php if (function_exists("gg_pagination")) { gg_pagination(); } ?> <?php // If no content, include the "No posts found" template. else : get_template_part( 'parts/post-formats/part', 'none' ); endif; ?> </div> <?php gg_page_sidebar(); ?> </div><!-- .row --> </div><!-- .container --> </section> 

`

    2 answers 2

    This is the template code archives.php , if I understand correctly. Then instead of <?php while (have_posts()) : the_post(); ?> <?php while (have_posts()) : the_post(); ?> try to use

    <?php query_posts($query_string.'&posts_per_page=100'); if (have_posts()) : while (have_posts()) : the_post(); ?>

    where 100 is the number of posts displayed. Display all posts - -1 .

    Note. This method will work for all category pages. To use it only for one category, you need to change the code.

    • so the page stops working: <? php query_posts ($ query_string. '& posts_per_page = 100'); if (have_posts ()): while (have_posts ()): the_post (); ?> - VINET 6:51 pm
    • Error 500. I also tried with -1 and closed if <? php endif; ?> - VINET
    • <ul class = "el-grid no_magnific" data-layout-mode = "fitRows" data-gap = "gap"> <? php query_posts ($ query_string. '& posts_per_page = 100'); if (have_posts ()): while (have_posts ()): the_post (); ?> .... <? php endif; ?> </ ul> - VINET
    • Strange. Unfortunately, I can't help you anymore. Google to turn off WordPress pagination, or if you are using a theme from the WordPress directory - it may have a setting for the number of displayed posts - malginovdesign
    • @IvanmalginovdesignMalginov, wp_reset_query(); forgot. Therefore, the five hundredth error fell most likely - alenkins

    The simplest way to change the number of entries displayed on blog pages is to change this number in the admin panel Настройки : Настройки => Чтение => На страницах блога отображать не более specify the number.

    Or change the query parameters like this:

     <section id="content"> <div class="container"> <div class="row"> <div class="<?php gg_page_container(); ?>"> <?php $args = $query_string . '&posts_per_page=-1'; $query = new WP_Query($args); if ($query->have_posts()) { ?> <div class="gg_posts_grid"> <ul class="el-grid no_magnific" data-layout-mode="fitRows" data-gap="gap"> <?php while ($query->have_posts()) { $query->the_post(); ?> <li class="isotope-item col-md-12"> <?php set_query_var('medical_services_thumb', 'medical-services-thumb-1col'); get_template_part('parts/medical-services/part', 'medical-service'); ?> </li> <?php } ?> </ul> </div> <?php if (function_exists("gg_pagination")) { gg_pagination(); } ?> <?php // If no content, include the "No posts found" template. } else { get_template_part('parts/post-formats/part', 'none'); } wp_reset_postdata(); ?> </div> <?php gg_page_sidebar(); ?> </div><!-- .row --> </div><!-- .container --> </section>