Title: unexpected T_ELSE in custom template code
Last modified: August 19, 2016

---

# unexpected T_ELSE in custom template code

 *  [clockworkjoe](https://wordpress.org/support/users/clockworkjoe/)
 * (@clockworkjoe)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/unexpected-t_else-in-custom-template-code/)
 * I made a special template based on the index.php of the execel theme. However,
   it is not working and I don’t know why.
 * the full error is Parse error: syntax error, unexpected T_ELSE line 50 which 
   is the ELSE line. I need that else in order for the template to look right.
 * Here is the code.
 *     ```
       <?php get_header(); ?>
   
       <?php
       $temp = $wp_query;
       $wp_query= null;
       $wp_query = new WP_Query();
       $wp_query->query('cat=6&showposts=3'.'&paged='.$paged);
       ?>
   
       <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
       <?php while (have_posts()) : the_post(); ?>
       			<ul class="pmeta">
       				<li>Posted by <?php the_author() ?></li>
       				<li>On <?php the_time('F j, Y') ?></li>
       				<li><br /><?php the_category(', ') ?></li>
       				<?php if (function_exists('the_tags')) { the_tags('<li>Tags ', '</li>'); } ?>
       				<li><br /><?php comments_popup_link('No Comments', '1 Comment', '% Comments' );?></li>
       				<?php edit_post_link('Edit', '<li>', '</li>'); ?>
       			</ul>
       			<div class="apost">
       				<h2 id="post-<?php the_ID(); ?>">
       <?php if (function_exists('get_cat_icon')) get_cat_icon('small=false'); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
       				<div class="pmain">
       					<!-- spost -->
   
       <?php the_content('Read more...'); ?>
   
       					<!-- epost -->
       				</div>
       <?php if ($count==1) { ?>
   
       <!-- PLACE YOUR 468x60 ADSENSE CODE (OR BANNER) BELOW -->
   
       <!-- PLACE YOUR 468x60 ADSENSE CODE (OR BANNER) ABOVE -->
   
       <?php } ?>
       <?php $count = $count + 1; ?>
   
       			</div>
   
       			<div class="extra"></div>
       <?php endwhile; ?>
   
       			<div class="lead">
       				<span class="ppre"><?php next_posts_link('&laquo; Previous Posts') ?></span>
       				<span class="pnex"><?php previous_posts_link('Next Posts &raquo;') ?></span>
       			</div>
       <?php else : ?>
       			<div class="apost">
       				<h2 class="subh">Oops!</h2>
       				<p class="nopost">Sorry, but you are looking for something that isn't here.</p>
       			</div>
       <?php endif; ?>
       		</div>
       	</div>
   
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/unexpected-t_else-in-custom-template-code/#post-779199)
 * you use curlies to contain the ‘if’ conditional, but you’re using the alternate
   syntax with a colon, on the else.
 * punctuation is important.
 * remove the curlies and put a : after your if.

Viewing 1 replies (of 1 total)

The topic ‘unexpected T_ELSE in custom template code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [ivovic](https://wordpress.org/support/users/ivovic/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/unexpected-t_else-in-custom-template-code/#post-779199)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
