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 nytt (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..


if ( in_category( 'nytt' ) || post_is_in_descendant_category( 49 ) ) {
$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

    global $more;
    $more = 0;

include(TEMPLATEPATH . '/includes/post-template.php');  



echo ('No posts available');


<div class="clear"></div>

Also I understand that I could be using the category.php to accomplish this as well, but as my theme was using archive.php by default I decided to use this instead. I've declared the [post_is_in_descendant_category] (http://codex.wordpress.org/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category)! function in my child themes functions.php.

Any help would be uber appreciated. Thanks for your time and expertise!

1 Answer 1


Firstly, do you have DEBUG set to TRUE in wp-config? Not loading further than the header may well mean there's an error that isn't displaying. Set it to True to see the error.

Secondly, you are using for in_category on an archive page - which I believe would only apply to the first post on the page. This may not make a difference in your case though.

Third, I would not use the default archive for this at all. I would create a template specifically for this category: category-nytt.php (see template hierarchy). This will both let you dispose of all the in_category/post_is_in_descendant_category gubbins entirely, and leave your default archive.php (once restored) to work in the standard way for standard posts.


See the answer here for having subcategories use their parent's template.

  • Hey @vancoder thanks for your suggestions. WP_Debug is set to false and from my understanding the category-[catname].php included in WP's template hierarchy doesn't work for sub-categories. My issue is that I have NYTT as a parent category and I want the custom layout properties outlined above to display when any of the sub-cats of NYTT are displayed in an archive or category format. Apr 11, 2013 at 19:42
  • My point about WP_DEBUG was that you should set it to true to see the error. Answer updated.
    – vancoder
    Apr 11, 2013 at 21:36
  • Thanks for your help on this. I followed your link for a solution to sub-categories using their parent's template and it came down to using this plugin which wickedly expands WP's template hierarchy.. http://wordpress.org/extend/plugins/category-template-hierarchy The first option he gave there didn't work for me although I tried it. Indeed WP_debug set to true revealed the errors. Thanks again for your time. I appreciate it greatly! Apr 25, 2013 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.