Title: Loop is causing white screen
Last modified: August 19, 2016

---

# Loop is causing white screen

 *  Resolved [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/loop-is-causing-white-screen/)
 * I’m havign some trouble with adding the loop to my page, it gives me a white 
   screen.
 * This is the loop I am using:
 *     ```
       <?php $my_query = new WP_Query("showposts=5&cat=18"); ?>
       <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
       <?php the_post_thumbnail(); ?>
       <a href="<?php the_permalink(); ?>"><H3><?php the_title(); ?></H3></a>
       <br><div class="wp-post-image">
       ```
   
 * If I remove the second line, the white screen doesn’t happen, but then it doesn’t
   work:
 * `<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>`
 * Thanks

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

 *  [simplistik](https://wordpress.org/support/users/simplistik/)
 * (@simplistik)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/loop-is-causing-white-screen/#post-1823700)
 * try turning on error reporting and see what it says:
 *     ```
       <?php
       ini_set('display_errors',1);
       error_reporting(E_ALL ^ E_NOTICE);
       ?>
       ```
   
 * put that at above your current code.
 * also you need to have `<?php endwhile; ?>` somewhere i don’t see it there but
   it also looks like you didn’t post all the code either.
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/loop-is-causing-white-screen/#post-1823793)
 * Thanks, that got it sorted for me 🙂

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

The topic ‘Loop is causing white screen’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/loop-is-causing-white-screen/#post-1823793)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
