Title: Trouble adding an Else Statement
Last modified: August 21, 2016

---

# Trouble adding an Else Statement

 *  [jmetzger631](https://wordpress.org/support/users/jmetzger631/)
 * (@jmetzger631)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/trouble-adding-an-else-statement/)
 * I’m having trouble adding an Else to this loop. It won’t validate 🙁
 *     ```
       <?php
       //if a certain page, then display posts authored by the logged in user
         global $current_user;
         get_currentuserinfo();
         echo 'User ID: ' . $current_user->ID . "\n";
         $args=array(
           'author' => $current_user->ID,
           'post_type' => 'wpbdp_listing',
         );
         $my_query = null;
         $my_query = new WP_Query($args);
         if( $my_query->have_posts() ) {
           while ($my_query->have_posts()) : $my_query->the_post(); ?>
             <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
   
            <h1>
            <a href="/therapist-directory/?action=editlisting&listing_id=<?php the_ID(); ?>
       ">Edit Your Profile</a>
   
            !</h1>
   
         <?php endwhile; else: ?>
       <p>Sorry, no posts matched your criteria.</p>
   
        <!-- REALLY stop The Loop. -->
        <?php endif; ?>
       ```
   

The topic ‘Trouble adding an Else Statement’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [jmetzger631](https://wordpress.org/support/users/jmetzger631/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/trouble-adding-an-else-statement/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
