Display child categories and if there are none display current posts
-
Hi, I
m having a problem displaying child categories. I
ve tried everything, I can get child categories displaying, but when I open them it says “No categories”. What I want to do is, if there are child categories, display them, if there are none, display a post from the current category. This seems next to impossible, Ive searched a bunch of forums, a lot of guys have this problem, but it seems there
s no real solution. I`ve gotten this far:<?php $cat_id = get_query_var('cat'); $catlist = wp_list_categories('orderby=id&title_li=&child_of=' . $cat_id); if ($catlist) echo $catlist; else { ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="archive"> <div class="thumb left"> <a>" rel="bookmark"><img src="<?php bloginfo('template_directory'); ?>/includes/timthumb.php?src=<?php get_thumbnail($post->ID, 'full'); ?>&h=170&w=250&" alt="<?php the_title(); ?>" /></a> </div> <!--end: thumb--> <h2><a>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_advanced_excerpt('length=160&use_words=0'); ?> <strong><h4><a>" rel="bookmark">[?itaj dalje...]</a></h4></strong> <div class="clear"></div> </div> <!--end: archive--> <?php endwhile; ?> <div class="clear"></div> <div class="pagenavi"> <div class="nextprev left"> <?php previous_posts_link('? Raniji ?lanci ') ?> </div> <div class="nextprev right"> <?php next_posts_link(' Noviji ?lanci ?') ?> </div> <div class="clear"></div> </div> <!--end: pagenavi--> <?php else : ?> <?php endif; ?> <?php }; ?>
But I cannot seem to get the posts displayed, all I get is “No categories” message. Please help! Thanks!
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Display child categories and if there are none display current posts’ is closed to new replies.