Title: &#8216;if while else&#8217; conditional content help required
Last modified: August 19, 2016

---

# ‘if while else’ conditional content help required

 *  [plinth](https://wordpress.org/support/users/plinth/)
 * (@plinth)
 * [16 years ago](https://wordpress.org/support/topic/if-while-else-conditional-content-help-required/)
 * Hi, I’m trying to create a custom template for a page that shows posts in a specific
   category, but can’t get the default ‘Sorry, no content found’ message to work
   when there’s no posts.
 * Here’s my code:
 *     ```
       <?php
       /*
       Template Name: Events in December
       */
       ?>
       <?php get_header(); ?>
   
       	<div id="dates">
           <ul>
           <?php wp_list_pages('title_li=&child_of=16'); ?>
           <ul>
           </ul>
           </div>
   
       	<div id="body_area">
   
       		<div id="text_left">
       		<div class="post" id="post-<?php the_ID(); ?>">
       		<div class="entry">
   
       <ul class="activities">
       <?php query_posts('category_name=december&showposts=0'); ?>
       <?php while (have_posts()) : the_post(); ?>
               <li><a href="<?php the_permalink(); ?>">
                 <h1><?php the_title(); ?></h1>
                 <h2><?php the_excerpt_rss(); ?></h2>
                 </a></li>
               <?php endwhile; ?>
       </ul>
       			</div>
       		</div>
       	</div>
           <div id="text_right"><?php get_sidebar(); ?></div>
       	</div>
       <?php get_footer(); ?>
       ```
   
 * Any suggestions?

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [16 years ago](https://wordpress.org/support/topic/if-while-else-conditional-content-help-required/#post-1444356)
 * See the examples [here](http://codex.wordpress.org/The_Loop) in the Codex.

Viewing 1 replies (of 1 total)

The topic ‘‘if while else’ conditional content help required’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [elseif](https://wordpress.org/support/topic-tag/elseif/)
 * [ifelse](https://wordpress.org/support/topic-tag/ifelse/)
 * [page template](https://wordpress.org/support/topic-tag/page-template/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/if-while-else-conditional-content-help-required/#post-1444356)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
