Search code examples
phpwordpress

wordpress all results in one page no pagination


I am using the code below at a wordpress theme called islemag to show results of a wp_query for posts. Results show up all good so far. Total results 16. 4 results per row. 3 rows total. 12 so far show up. Then pagination options show up so i can navigate to the next page. I click and the rest 4 show up on second page. What is the best way to change this code to show up all 16 results in one page with no pagination? Any help appreciated.

    <?php
    get_header();

    if ( $wp_query->have_posts() ) : ?>
        <div class="col-md-9 post-section islemag-template1">
        <div style="font-size:50px;">
            <?php //$cat = get_the_category(); echo $cat[0]->cat_name;
            echo '<h2 class="title-border title-bg-line red mb30">
                    <span>Product Categories</span>
                </h2>';?></div>
        <div class=" islemag-template1-posts smaller-nav no-radius">
            <?php

            while ( $wp_query->have_posts() ) :
                $wp_query->the_post();
    $category = get_category( get_query_var( 'cat' ) );
    $cat_id = $category->cat_ID;

            ?>
    <div class="col-md-3 col-xs-6">
        <div class="panel panel-default">
            <div class="panel-image text-center">
                <figure>


    <?php
    echo "<a href=/category/".str_replace(" ","-",get_the_title())."/>";
                    echo '<img src="'.get_field('picture_url').'">
    </img>';?></a>
                </figure> <!-- End figure -->
            </div>
            <div class="panel-body">
                            <span class="panel-shopname">

                </span>

                <?php $subtitle=get_the_title();

                            echo "<a href=/category/".str_replace(" ","-",$subtitle)."/>";
                ?>
                <h4 class="panel-promotitle"><?php 
    echo $subtitle."...";
?></h4></a>
            </div>
        </div>
    </div>
            <?php

                endwhile;
            ?>
        </div> <!-- End .islemag-template1-posts -->
        </div> <!-- End .islemag-template1 -->

    <?php
        endif;

    ?>

    <?php get_sidebar();?>
    <?php get_footer();?>

Solution

  • in functions.php add

     function wpse_disable_pagination( $query ) {
       if($query->is_page('your-page') ) {
          $query->set( 'nopaging' , true );
       }
     }
    add_action( 'pre_get_posts', 'wpse_disable_pagination' );