Skip to content

Instantly share code, notes, and snippets.

@siddhartanaranjo
Last active December 19, 2015 09:59
Show Gist options
  • Save siddhartanaranjo/5937140 to your computer and use it in GitHub Desktop.
Save siddhartanaranjo/5937140 to your computer and use it in GitHub Desktop.
function list_my_categories
/* List categories of categories page */
function list_my_categories($exclude = '') {
if (!empty($exclude)) {
$exclude = 'exclude=' . $exclude;
}
$categories = get_categories($exclude);
$categories = get_categories($args);
$html = '';
foreach ($categories as $cat) {
if($cat->category_parent == 0) {
$html .= '<div class="span12 blueBackground service_name service_title">
<h2 class="product_name_title">' . $cat->cat_name;
$html .= '</h2></div>';
$childcategories = get_categories('child_of='.$cat->cat_ID.'');
if(!empty($childcategories)){
$html .= '<div class="span12 subCategoria">';
foreach ($childcategories as $ccat) {
$html .= '<div class="span4 blueBackground service_name">
<a href="'.get_category_link( $ccat->term_id ).'">
<h2 class="product_name_title">'. $ccat->cat_name;
$html .= '</h2></a></div>';
}// for each childcategories
$html .= '</div>';
} // if child categories
} // if category
} // for each categories
$html .= '';
return $html;
} // function
// llamo la funcion con <?php echo list_my_categories(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment