WordPress.org

Ready to get started?Download WordPress

Forums

Categories, sub-categories with images (1 post)

  1. sakarya
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic