• Hello all,

    Here is a snippet of the news / blog template being used. No matter what is changed from the Reading panel to changing the code directly, the page will only show 1 post.

    Would anyone be able to point me in the right direction? I have changed the ‘posts_per-page’ a few different ways and a handful of other tweaks with no prevail.

    Thanks all!

    <div class="container">
    			<div class="masonry-grid">
    				<div class="grid-sizer"></div>
    				<div class="gutter-sizer"></div>
    				 <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    		        $temp = $list_of_posts;
    				$list_of_posts= null;
    				$list_of_posts = new WP_Query();
    				$list_of_posts->query('posts_per_page=-1'.'&paged='.$paged);
    
    		        //var_dump($list_of_posts);
    		        ?>
    		        <?php if ( $list_of_posts->have_posts() ) : ?>
    					<?php /* The loop */ ?>
    					<?php while ( $list_of_posts->have_posts() ) : $list_of_posts->the_post(); ?>
    						<!-- Item -->
    						<div class="item w2">
    							<div class="post-tile">
    								<a href="<?php the_permalink(); ?>" class="post-thumb">
    									<!-- Featured Image | post_thumbnail() -->
    									<?php if ( has_post_thumbnail() ) : ?>
    										<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    										<?php the_post_thumbnail( 'blog_archive_thmub', array( 'class' => 'blog_archive_thumbnail post-thumb' ) ); ?>
    										</a>
    									<?php endif; ?>
    								</a>
    								<div class="post-body">
    									<div class="post-title">
    										<a href="/news/">
    											<h3><?php the_title(); ?></h3>
    										</a>
    										<span><?php the_excerpt(); ?></span>
    									</div>
    									<?php srh_framework_entry_footer(); ?>
    								</div>
    							</div>
    						</div>
    					<?php endwhile; ?>
    
    					<?php// twentythirteen_paging_nav(); ?>
    
    				<?php else : ?>
    					<?php get_template_part( 'content/content', 'none' ); ?>
    				<?php endif; ?>
    
    			</div>
    			<!-- Pagination -->
    			<?php// twentythirteen_paging_nav(); ?>
    		</div>
    	</section><!-- Blog Grid End -->
       <?php wp_reset_query(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • if you want to see all posts, try to add a ‘post_type’ parameter to the query.

    what is the full code of the template?

    Thread Starter M S

    (@mgstults)

    Thanks Michael for the reply. There isn’t much more than the above but here is the whole thing. I feel that the original developer using a mesh up of Underscores, 2013, and a premium theme didn’t hook everything in to work. At least that seems to be common on other issues.

    <?php
    /*
    Template Name: News
    */
    
    /* This example is for a child theme of Twenty Thirteen:
    *  You'll need to adapt it the HTML structure of your own theme.
    */
    
    get_header(); ?>
    
    	<!-- Blog Grid -->
    	<section class="space-top padding-bottom">
    		<div class="container">
    			<div class="masonry-grid">
    				<div class="grid-sizer"></div>
    				<div class="gutter-sizer"></div>
    				 <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    		        $temp = $list_of_posts;
    				$list_of_posts= null;
    				$list_of_posts = new WP_Query();
    				$list_of_posts->query('posts_per_page=-1'.'&paged='.$paged);
    
    		        //var_dump($list_of_posts);
    		        ?>
    		        <?php if ( $list_of_posts->have_posts() ) : ?>
    					<?php /* The loop */ ?>
    					<?php while ( $list_of_posts->have_posts() ) : $list_of_posts->the_post(); ?>
    						<!-- Item -->
    						<div class="item w2">
    							<div class="post-tile">
    								<a href="<?php the_permalink(); ?>" class="post-thumb">
    									<!-- Featured Image | post_thumbnail() -->
    									<?php if ( has_post_thumbnail() ) : ?>
    										<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    										<?php the_post_thumbnail( 'blog_archive_thmub', array( 'class' => 'blog_archive_thumbnail post-thumb' ) ); ?>
    										</a>
    									<?php endif; ?>
    								</a>
    								<div class="post-body">
    									<div class="post-title">
    										<a href="/news/">
    											<h3><?php the_title(); ?></h3>
    										</a>
    										<span><?php the_excerpt(); ?></span>
    									</div>
    									<?php srh_framework_entry_footer(); ?>
    								</div>
    							</div>
    						</div>
    					<?php endwhile; ?>
    
    					<?php// twentythirteen_paging_nav(); ?>
    
    				<?php else : ?>
    					<?php get_template_part( 'content/content', 'none' ); ?>
    				<?php endif; ?>
    
    			</div>
    			<!-- Pagination -->
    			<?php// twentythirteen_paging_nav(); ?>
    		</div>
    	</section><!-- Blog Grid End -->
       <?php wp_reset_query(); ?>
    
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘posts_per_page query only showing 1 no matter what’ is closed to new replies.