Title: if have_posts &#8230; else
Last modified: August 19, 2016

---

# if have_posts … else

 *  [bonanza9](https://wordpress.org/support/users/bonanza9/)
 * (@bonanza9)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/if-have_posts-else/)
 * hi
 * i’m working on an author profile page, where i’d like to include the author name,
   description, and (links to) their posts.
 * i have an author.php page with:
 *     ```
       <?php
       if(isset($_GET['author_name'])) :
       $curauth = get_userdatabylogin($author_name);
       else :
       $curauth = get_userdata($author);
       endif;
       ?>
       .
       .author name, author description
       .
       <!-- The Loop -->
       <?php if ( have_posts() ) : ?>
       <?php while ( have_posts() ) : the_post(); ?>
       <li>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
       <?php the_title(); ?></a>,
       <?php the_time('d M Y'); ?> in <?php the_category('&');?>
       </li>
       <?php endwhile; ?>
       <?php else: ?>
       <h2 class="center">Nope</h2>
       <?php endif; ?>
       <!-- End Loop -->
       ```
   
 * this works fine when the user has posted stuff, but when they haven’t it displays
   the ‘Not found…’ i.e. the comment i have in my else statement on my index.php.
 * any one know why it doesn’t display the user profile, followed by a ‘nope’?
 * thanks in advance,
 * b9

The topic ‘if have_posts … else’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [bonanza9](https://wordpress.org/support/users/bonanza9/)
 * Last activity: [17 years, 8 months ago](https://wordpress.org/support/topic/if-have_posts-else/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
