• Andrew

    (@cipes)


    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.