We help IT Professionals succeed at work.

Exclude Categorys and any child category associated with it.

Jon Imms
Jon Imms asked
on
572 Views
Last Modified: 2012-02-15
Hi,  I have a function which is display all categorys, with the exception of blogposts (ID33).

I am now told that blog posts will have child categorys. How can i modify this function, so that it excludes category 33 and any child of it.

 <?php
add_shortcode('caticons_listing2','bm_caticons_listing');
function bm_caticons_listing() {
    $listing_code = '';
    $category_link = '';
    foreach(get_categories("orderby=name&order=ASC&exclude=33") as $category) {
		$category_link = get_category_link( $category->cat_ID );
		$category_link = esc_url( $category_link );
		$listing_code .= '<div class="et_pt_blogentry clearfix">' ;
       	$listing_code .= ''.get_cat_icon("echo=false&cat=".$category->cat_ID).'';
		$listing_code .= '<h2 class="et_pt_title"><a href="'.$category_link.'">'.$category->cat_name.'</a></h2><span class="category-description">'.$category->description.'</span>';
		$listing_code .= '</div>' ;                      	
    }
    $listing_code .= '';
    return $listing_code;
}
?>

Open in new window

Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.