Title: Loop only displaying one post.
Last modified: August 24, 2016

---

# Loop only displaying one post.

 *  [Luke](https://wordpress.org/support/users/lukejongibson/)
 * (@lukejongibson)
 * [11 years ago](https://wordpress.org/support/topic/loop-only-displaying-one-post/)
 * Hi,
 * I’ve got the following code and it’s only displaying the latest post, any idea
   why it’s only showing one post? It used to work but something changed and now
   it’s broken. I’m thinking maybe an update to the latest version of WordPress 
   and now it’s using some depreciated code.
 * Cheers
 *     ```
       <?php get_header(); ?>
   
       	<div id="primary" class="content-area">
       		<main id="main" class="site-main row" role="main">
       		<?php
         $temp = $wp_query;
         $wp_query = null;
         $wp_query = new WP_Query();
         $wp_query->query('showposts=6&post_type=post'.'&paged='.$paged); 
   
         while ($wp_query->have_posts()) : $wp_query->the_post();
       ?>
       				<article id="post-<?php the_ID(); ?>" <?php post_class('col-sm-6'); ?>>
   
       	<div class="entry-content">
       <?php
   
         echo '<div class="ashi-content">';
         ?>
        <a href="<?php the_permalink(); ?>">
          <?php echo '<div class="ashi-imagehead">';
   
       if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
       	the_post_thumbnail( 'large' );
       }
         echo '</div>';
   
          echo '<h2>';
   
           the_title();
             echo '</h2>';
       echo '</a>';
   
             echo '<p class="ashi-date">';
        the_time('F j, Y');
             echo '</p>';
             echo '<div class="ashi-excerpt">';
   
       the_excerpt();
             echo '</div>';
                 echo '<div class="ashi tags">';
         the_tags();
         echo '</div>';
   
         echo '</div>';
   
       	?>
       </article><!-- #post-## -->
   
       			<?php endwhile; // end of the loop.
       			?>
       		<div class="paged-nav">
           <div class="prev"><?php previous_posts_link('&laquo; Back') ?></div>
           <div class="next"><?php next_posts_link('Next &raquo;') ?></div>
       </div>
   
       <?php
         $wp_query = null;
         $wp_query = $temp;  // Reset
       ?>
       </div>
       		</main> <!-- #main -->
       	</div> <!-- #primary -->
   
       <?php get_footer(); ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Phil](https://wordpress.org/support/users/websterwebguru/)
 * (@websterwebguru)
 * [11 years ago](https://wordpress.org/support/topic/loop-only-displaying-one-post/#post-6154538)
 * Hello,
 * I know these things can be frustrating. It looks like you have some old code 
   here. showposts was deprecated. You now need to use posts_per_page. I would also
   check out [https://codex.wordpress.org/Class_Reference/WP_Query#Description](https://codex.wordpress.org/Class_Reference/WP_Query#Description)
   for the new usage of WP_Query
 *  Thread Starter [Luke](https://wordpress.org/support/users/lukejongibson/)
 * (@lukejongibson)
 * [11 years ago](https://wordpress.org/support/topic/loop-only-displaying-one-post/#post-6154552)
 * I thought that might be the case, thank you.
 *  Thread Starter [Luke](https://wordpress.org/support/users/lukejongibson/)
 * (@lukejongibson)
 * [11 years ago](https://wordpress.org/support/topic/loop-only-displaying-one-post/#post-6154634)
 * Okay so I updated the code, but still have the problem.
 * I’m trying to get the posts to display on a standard page. Not the main posts
   page selected in the setting menu.
 *     ```
       <?php
       /*
       Template Name: News Decoded
       */
       ?>
       <?php get_header(); ?>
       <div id="primary" class="content-area">
       <?php query_posts('cat=1,2,3,4,5,6,7,8,9,10&posts_per_page=6'); ?>
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       <article id="post-<?php the_ID(); ?>" <?php post_class('col-sm-6'); ?>>
       <div class="entry-content">
   
       <div class="ashi-content">
        <a href="<?php the_permalink(); ?>"><div class="ashi-imagehead">
   
       <?php the_post_thumbnail( 'large' );  ?>
       </div>
   
       <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
       <p class="ashi-date">
        <?php the_time('F j, Y'); ?>
           </p>
           <div class="ashi-excerpt"><?php the_excerpt(); ?></div>
            <div class="ashi tags"><?php the_tags(); ?></div>
       </div>
       </article><!-- #post-## -->
   
       <?php endwhile; else: ?>
   
       	<p>Sorry, no posts to list</p>
   
       <?php endif; ?>
   
       <div class="paged-nav">
           <div class="prev"><?php previous_posts_link('&laquo; Back') ?></div>
           <div class="next"><?php next_posts_link('Next &raquo;') ?></div>
       </div>
   
       </div>
       	</div> <!-- #primary -->
       <?php get_footer(); ?>
       ```
   
 * Any ideas what I’m still doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Loop only displaying one post.’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Luke](https://wordpress.org/support/users/lukejongibson/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/loop-only-displaying-one-post/#post-6154634)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
