I modified my category.php file to pull posts from all the categories that are posted to a main category parent. It's working perfectly. Now I need to get it so that when you click on the child category permalink, it will take you to that category and list all the posts from that category. That's not working perfectly. When I click on the permalink which is
myDomain.com/?cat=12
I get a blank page. This is my category.php file as it is right now. Well, the relevant stuff, I left out the header and footer
<div id="subpageHolder">
<div id="subPage">
<div id="menu">
<img src="<?php bloginfo('stylesheet_directory');?>/images/menu.png" width="137" height="30" alt="Our Menu" />
<div class="clear"></div>
<?php
$allcats = get_categories(array('child_of' => get_query_var('cat'), 'number' => 9999, 'order'=> 'asc'));
?><ul id="slider1" style="width: 166px;"><?php
foreach ($allcats as $cat) :
$args = array(
'category__in' => array($cat->term_id)
);
query_posts($args);
if (have_posts()) :
?><li><?php
echo '<div class="menupageContent">';
$terms = apply_filters( 'taxonomy-images-get-terms', '' );
if ( ! empty( $terms ) ) {
foreach( (array) $terms as $term ) {
if($term->term_id == $cat->term_id) {
echo wp_get_attachment_image( $term->image_id, 'menu' );
}
}
}
$link = get_category_link( $cat->cat_ID );
echo '<h3><a href="'. $link . '">'.$cat->name.'</a></h3>';
echo '<ul>';
while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
echo '</ul></div><!--end menupageContent--></li>';
?>
<?php else : ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
echo 'No post published in:'.$cat->name;
<?php endif; ?>
<?php
endif;
wp_reset_query();
endforeach;
?>
</ul>
So is it possible to throw in another else loop? when I tried it, it didn't work. I had hoped the archive.php file would take care of it but it didn't. I tried a few loops with no luck. I need some good advice as to how to get this to work. Thanks for your time.
$allcats
variable for null. You are probably setting the'category__in'
argument to null, or 0, or something that is not valid when a category does not have child categories.