Categories, sub-categories with images
-
Hello.
Using this code for listing categories with images.
<?php $image_path = get_bloginfo('stylesheet_directory'); $cats = get_categories(); $count=1; foreach ((array)$cats as $cat) { $catdesc = attribute_escape(strip_tags($cat->category_description)); $image = $cat->category_nicename .'.jpg'; $cat_img = '<div class="category-image" id="cat-image-'.$count.'"'.'><a href="' . get_category_link($cat) . '" title="'. $catdesc .'"><img class="image-for-category" src="' . $image_path . '/images/' . $image . '" alt="' . $cat->cat_name . '" /></a></div>'."\n\n"; echo $cat_img ; $count++; } ?>
But I have sub-categories and I dont want to add images for sub-categories.
How can i do it?
I will create a theme like Directory Press.
- The topic ‘Categories, sub-categories with images’ is closed to new replies.