Title: If statement in Archive.php
Last modified: August 20, 2016

---

# If statement in Archive.php

 *  [Andrew](https://wordpress.org/support/users/cipes/)
 * (@cipes)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/if-statement-in-archivephp/)
 * Hi Folks,
    I’ve got a small issue with my archive.php. I was trying to set up
   an If statement that displays a certain category and sub categories with a different
   layout & sidebar based on my theme options. I’ve placed a small bit of code in
   the start of my archive.php in order to set these options based on if the post
   is in category ‘nytt’ or is a sub cat of nyytt (ID 49). It works like a charm,
   if the category listing in part of NYTT or a sub cat, but now, all other categories
   don’t display, the page won’t load further than the header. And for the life 
   of me I can’t figure out why. I’m staring at this code like it holds a secret
   which it won’t give up..
 *     ```
       <?php
       get_header();
   
       $subtitle=get_opt("_posts_subtitle");
       $slider='none';
       if ( in_category( 'nytt' ) || post_is_in_descendant_category( 49 ) ) {
       	$layout='left';
       	$sidebar ='teacher-training';
       }
       else {
       	$layout = get_opt('_blog_layout');
       	$sidebar = get_opt('_blog_sidebar');
       }
   
       include(TEMPLATEPATH . '/includes/page-header.php');
   
       ?>
   
       <div id="content-container" class="content-gradient <?php echo $layoutclass; ?> ">
       <div id="<?php echo $content_id; ?>"><?php
   
       if(have_posts()){
       	while(have_posts()){
       		the_post();
       		global $more;
       		$more = 0;
   
       	include(TEMPLATEPATH . '/includes/post-template.php');	
   
       	} 
   
       	print_pagination(); 
   
       }else{
       	echo ('No posts available');
       }
   
       ?>
       </div>
       <?php
       if($layout!='full'){
       	 print_sidebar($sidebar);
       }
       ?>
   
       <div class="clear"></div>
       </div>
       <?php
       get_footer();
       ?>
       ```
   
 * Any help would be awesome. Thanks for your time!

The topic ‘If statement in Archive.php’ is closed to new replies.

## Tags

 * [archive.php](https://wordpress.org/support/topic-tag/archive-php/)
 * [if statements](https://wordpress.org/support/topic-tag/if-statements/)
 * [sub-categories](https://wordpress.org/support/topic-tag/sub-categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Andrew](https://wordpress.org/support/users/cipes/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/if-statement-in-archivephp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
