troubleshooting Question

Exclude Categorys and any child category associated with it.

Avatar of Jon Imms
Jon ImmsFlag for United States of America asked on
1 Comment1 Solution576 ViewsLast Modified:
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.

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;

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros