Permalink
Browse files

show child categories in homepage

  • Loading branch information...
tareq1988 committed Sep 23, 2014
1 parent 989972d commit 043b107c71efb52aafde9cc09e83453215569faf
Showing with 33 additions and 1 deletion.
  1. +6 −1 index.php
  2. +27 −0 templates/loop-category.php
View
@@ -12,7 +12,12 @@
<?php } ?>
<?php
$categories = get_terms( 'category', array('hide_empty' => false, 'orderby' => 'name', 'parent' => 0) );
$categories = get_terms( 'category', array(
'hide_empty' => false,
'orderby' => 'name',
'parent' => 0,
'hierarchical' => false
) );
if ( $categories ) {
@@ -5,5 +5,32 @@
<?php if ( !empty( $category->description ) ) { ?>
<?php echo $category->description; ?>
<?php } ?>
<?php
$args = array(
'hide_empty' => false,
'orderby' => 'term_id',
'child_of' => $category->term_id,
'title_li' => '',
'show_option_none' => ''
);
echo '<ul class="child-cats">';
wp_list_categories( $args );
echo '</ul>';
/*
$childrens = get_terms( 'category', $args );
if ( $childrens ) {
echo '<ul class="child-cats">';
foreach ($childrens as $child) {
// printf( '<li><a href="%s">%s</a></li>', get_term_link( $child ), $child->name );
}
echo '</ul>';
}
*/
?>
</div>
</li>

0 comments on commit 043b107

Please sign in to comment.