Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //# getting the main category of the page
- $catid = get_query_var('cat');
- $cat = get_category( $catid );
- //#check if this is top-level cat//
- if( !$cat->parent ) : //there is no parent cat, therefore this is the top cat//
- //# now letz get the children categories of the main category
- $categories = get_categories('child_of='.intval($catid));
- foreach ($categories as $category) {
- //# check if it is a real parent category with subcategories
- if ($category->parent == $catid):
- echo
- '
- <div class="cat-item">
- <div class="image">'.get_cat_icon("echo=false&cat=".$category->cat_ID).'</div>
- <div class="text">
- <a href="'.get_category_link($category->term_id ).'">'.$category->cat_name.'</a>
- </div></div>
- '
- ;
- endif; //ends 'if ($category->parent == $catid):'
- }
- else : //#not the top cat//
- //insert the (normal) loop to output the category posts if the cat is not top level//
- endif;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement